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.

ChangesInRails23

This page shows changes in Rails 2.3 that affect the sample code in the book. 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.

8.1 Sessions

Page 99/107: the line to uncomment in environment.rb now looks as follows:

ActionController::Base.session_store = :active_record_store

Page 100/108: The setup is now done in config/initializers/session_store.rb

Page 100/108: there no longer is a need to uncomment out the :secret parameter in application.rb (which is now named application_controller.rb)

8.3 Iteration C2: Creating a Smarter Cart

Page 106/114: Immediately after calling rake db:sessions:clear (i.e., before any other access to the web server that might create a session), the server (say, WeBrick launched by ruby script/server) needs to be restarted. In some cases, you may have to manually delete the browser’s cookie file.

8.5 Iteration C4: Finishing the Cart

Page 114/122: After adding the implementation of the total_price method, I found that I had to restart the server in order for this change to be picked up.

11.1 Iteration F1: Adding Users

Page 158/164: The preferred way to order the users returned in the index is now:

@users = User.all(:order => :name)

Page 160/166: Scaffold generated code for index.html.erb now uses a block to do iteration instead of a for loop

14.3 Functional Testing of Controllers

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, starting with Rails version 2.3.4. Bug 3198

Page 433/437: starting with Rails 2.3.6, overwrite_params will be deprecated. To get the same effect, you will need to specify each parameter.

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.11 Adding New Templating Systems

Page 557/560: the render method in RDocTemplate now needs to have two parameters, thus:

def render(template, local_assigns = {})

Page 558/560: application.rb is now application_controller.rb

Page 559/562: the same change needs to be made to the render function in EvalTemplate too

Page 559/562: remove call to :evaluate_assigns

Page 559/562: the line that starts with template.locals.each now looks as follows: