Want to receive a weekly email containing
the scoop on our new titles along with the
occasional special offer? Just click the button.
(You can always unsubscribe later by editing your
account information).

Give us an email and a password (you can use the password later to log in and
change your preferences). We'll send you a newsletter roughly once a week.

ChangesInRails30

This page is incomplete

At the moment, it only represents a first pass at sections 4-13.

Once complete, this page is intended to shows changes in Rails 3.0 that affect the sample code in Agile Web Development with Rails, Edition 3. As page numbers in the paper and PDF copies differ, this information is organized first by section number, then it lists both page numbers, paper copy first.

Meanwhile, a live status of an updated Edition 3 scenario (as well as a developing Edition 4 scenario) under various versions of Rails and Ruby is available. Note that page is based on pulling Rails from git (and for 1.8.8 and 1.9.2, Ruby from svn) so it will often reflect failures that will not ever make it in beta or RC form.

Global changes

The names of scripts have changed:

Rails 2.2

Rails 3.0

ruby script/about

rake about

ruby script/console

rails console

ruby script/dbconsole

rails dbconsole

ruby script/destroy

rails destroy

ruby script/performance/benchmarker

rails benchmarker

ruby script/performance/profiler

rails profiler

ruby script/generate

rails generate

ruby script/plugin

rails plugin

ruby script/runner

rails runner

ruby script/server

rails server

3.0 Installing Rails

Page 21/32 : Rails now requires Ruby 1.8.7 or later. This particularly affects Windows users as both InstantRails and RubyInstaller bundle Ruby 1.8.6. RubyInstall RC2 development is underway, but for now we can use Cygwin .

4.1 Creating a New Application

Page 36/45 : After cd demo and before rails server (was: ruby script/server), edit config/routes.rb, and uncomment the following line:

match ':controller(/:action(/:id(.:format)))'

6.1 Getting Something Running

Page 63/71 : options must now come after the app path, so you would specify mysql as the database as follows:

rails depot --database=mysql

6.3 Adding a Missing Column

Page 73/81: the h’s are no longer present in the template.

Page 74/82: instead of editing new.html.erb and edit.html.erb files, edit _form.html.erb. Instead of a <p> tag, you will see <div class="field">

Page 75/83: the h’s are no longer present in the template.

Page 76/84: instead of deleting the h, add the word raw.

7.1 Creating the Catalog Listing

Page 87/95 : Edit config/routes.rb, and uncomment the following line, and then restart the server:

14.2 Unit Testing of Models

Page 209/214: lines of the form product.errors.invalid?(:title) need to be changed to product.errors[:title].any?

14.3 Functional Testing of Controllers

Page 221/226: application.rb is now application_controller.rb

16.2 Enumerations and Arrays

Page 273/277: :skip_last_comma has been deprecated. Use :last_word_connector instead.

16.9 Unicode support

Page 283/287: name.chars.reverse is now name.mb_chars.reverse

Page 284/288: person.name.chars is now person.name.mb_chars (twice on this page)

21.2 Routing Requests

Page 424/428: add the following as the first action after starting script/console:

ActionController::Base.session_store = nil

Page 431/436: some of these examples return /blog/show_date?... instead

21.4 Testing Routing

Page 455/459: the excerpt in the book doesn’t show it, but if you download routing_conditions_test.rb and wish to execute it, you will need to add require "config/routes_with_conditions.rb" to the beginning of config/routes.rb. After this is done, you can remove the setup method entirely from RoutingTest as it is unnecessary.

23.3 Helpers for Formatting, Linking, and Pagination

Page 518/521: A new version of the will_paginate gem is required, and the installation instructions have changed:

Install the gem using gem install will_paginate --pre

Either add require 'will_paginate' to config/application.rb or add gem 'will_paginate', '3.0.pre' to your Gemfile and make use of bundler . The Rails team recommends bundler for Rails 3.0.