Code from the e-book learn-rails