small medium large xlarge



This page 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 rails rails new 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.

3.2 Installing on Windows

  • Page 21/31: As InstantRails bundles Ruby 1.8.6, it is no longer a viable starting point for Rails 3.0 usage. Try one of the following alternatives: RubyInstaller on Cygwin

3.4 Installing on Ubuntu

  • Page 25/35: libfcgi-dev also needs to be installed via aptitude before the installation of rails itself.

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)))'
  • Page 41/50: Instead of putting the entire HTML file into say/hello.html.erb, simply put the following line:
    • <h1>Hello from Rails!</h1>
  • Page 46/55: the hello.html.erb files you see in this chapter should only contain the lines between the and tags.
  • Page 49/58: the goodbye.html.erb files you see in this chapter should only contain the lines between the and tags.

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

    tag, you will see

  • 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.

6.5 Making Prettier Listings

  • Page 83/??: depot_b/app/views/layouts/products.html.erb
    • You need to add <%= javascript_include_tag :defaults %> <%= csrf_meta_tag %> to the <head> section for working delete method.

7.1 Creating the Catalog Listing

  • Page 83/91: instead of a per scaffold layout, there is a single common applications.html.erb which is a bit more generic than the layout shown in the book.
  • Page 87/95: Edit config/routes.rb, and uncomment the following line, and then restart the server:
    • match ':controller(/:action(/:id(.:format)))'
  • Page 89/97: remove the h before product.title, add raw before product.description

8.1 Sessions

  • Page 99/107: the line to uncomment in environment.rb now looks as follows:
    • Rails.application.config.session_store :active_record_store
  • Page 100/107: 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)

9.2 Iteration D2: Creating an Ajax-Based Car

  • Page 123/130: change line containing form_remote_tag :url=>... to:
    • <%= form_tag({:action=>'add_to_cart', :id=>product}, :remote=>true) do %>

9.4 Iteration D4: Hiding an Empty Cart

  • Page 131/138: add an equals to the hidden_div_if line, thus:
    • <%= hidden_div_if(...) do %>

h4.10.1 Iteration E1: Capturing a User

* Page 141/148: add an equals to the form_for line, thus: In place of error_messages_for, insert the following code:

          <% if @order.errors.any? %>
            <div id="errorExplanation">
              <h2><%= pluralize(@order.errors.count, "error") %>
                prohibited this order from being saved:</h2>
              <% @order.errors.full_messages.each do |msg| %>
                <li><%= msg %></li>
              <% end %>
          <% end %>
* Page 141/148: add an equals to the form_for line, thus: * <%= form_for :order, :url => { :action => :save_order } do |form| %>

11.1 Iteration F1: Adding Users

  • Page 158/164: The preferred way to order the users returned in the index is now:
    • @users = User.order(:name)
  • Page 159/165: Instead of a separate line assigning flash[:notice], there now is a :notice parameter on the format.html call.
  • Page 160/166: Scaffold generated code for index.html.erb now uses a block to do iteration instead of a for loop
    • <% @users.each do |user| %>
  • Page 160/166: Insert the following at the top of app/views/users/index.html
    • <p class="notice"><%= notice %></p>
  • Page 160/166: The form can now be found in app/views/users/_form.html.erb
  • Page 160/166: use of form_for now requires the use the <%= syntax
  • Page 161/167: there is no app/views/layouts/users.html.erb to be updated, or even a need to update anything as this change has already been made to the common application layout.

11.2 Iteration F2: Logging In

  • Page 163/169: use of form_for now requires the use the <%= syntax

11.3 Iteration F3: Limiting Access

  • Page 166/172: application.rb is now application_controller.rb

11.4 Iteration F4: A Sidebar, More Administration.

  • Page 168/174: application.rb is now application_controller.rb
  • Page 168/174: instead of adding a line declaring a layout of “store”, modify the exiting line that indicates a layout of “application” to say layout “store”.
  • Page 169/174: use of hidden_div_if now requires use the <%= syntax

13.1 Iteration I1: Enabling Translation

* Page 187/193: omit the setting of LOCALES_DIRECTORY (alternately, use Rails.root instead of RAILS_ROOT). * Page 188/194: use of form_for now requires the use the <%= syntax * Page 190/196: application.rb is now application_controller.rb * Page 191/197: use of form_tag now requires the use the <%= syntax * Page 193/199: use of form_remote_tag now requires the use the <%= syntax * Page 193/199: change main.title to main.title_html in order to use html entities. * Page 194/200: change es.main.title to * Page 197/203: use of form_for now requires the use the <%= syntax * Page 197/203: In place of the h2 line (not shown in book, inserted in section 10.1 above), insert the following:

    <h2><%= I18n.t('errors.template.header', :count=>@order.errors.size,
          :model=>I18n.t('activerecord.models.order')) %>:</h2>
* Page 199/205: es.activerecord.errors.template becomes es.errors.template: *
Insert line ” errors:” before ” activerecord:” ** Move 5 lines starting with “template:” through “other:” before “activerecord:”, unindenting by two characters * Page 200/205: error messages are double escaped. Bug 2409

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: is now (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 425/429: it is no longer possible to get Rails routing to pretend the application contains controllers that have not been written yet.
Page 430/435: rs.generate “store” now produces /store/index and rs.generate “store”, :id => 123 now produces /store/index?id=123.
Page 431/436: some of these examples return /blog/show_date?... instead
Page 433/427: overwrite_params is no longer supported. To get the same effect, you now 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 Action View

Page 505-560/508-562 Every example of the form <% ... do > needs to be converted to <= ... do %>

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:
    add gem 'will_paginate', '>= 3.0.pre' to Gemfile
    execute bundler install

23.11 Adding New Templating Systems

Page 557/560: Updated rdoc_template that works with Rails 3.0.
Page 558/560: application.rb is now application_controller.rb
Page 558/561: you will also need to add gem 'rdoc' to your Gemfile
Page 558/561: name the templates example.html.rdoc and test.text.reval respectively.
Page 559/563: Updated eval_template that works with Rails 3.0.

25.1 Sending E-mail

Page 611/613: confirm.erb can now be found in confirm.text.erb
Page 612/614:
    the second parameter to truncate now must be a hash, thus: :length => 50.
    order_mailer.rb can now be found in the app/mailer directory (this change also applies to the next page)
    _line_item.erb should now be named _line_item.text.erb
Page 614/616:
    sent.erb should now be named sent.html.erb. Additionally, remove the sent.text.erb that was generated.
    change render(:partial => "html_line_item") to render(:partial => "line_item")

25.3 Testing E-mail

Page 621/623: replace the following files:
    test/unit/order_mailer_test.rb (to be placed in the test/functional directory)

Pour sécuriser efficacement les valeurs, bijoux et disques durs, l’installation d’un coffre fort est indispensable : voir le site

26.2 Show Me the Code!

Page 626/628: After cd depot_client, edit config/routes.rb, and uncomment the following line:
    match ':controller(/:action(/:id(.:format)))'
Page 628/630: application.rb is now application_controller.rb

26.3 Relationships and Collections

Page 630/632: the config/routes.rb line now needs to look like this:
    resources(:orders) { resources :line_items }
Page History
  • V84: eric tenne [14 days ago]
  • V83: Ellie @ Support [almost 2 years ago]
  • V84: Ellie @ Support [almost 2 years ago]
  • V84: Ellie @ Support [about 2 years ago]
  • V125: Ellie @ Support [about 2 years ago]
  • V118: System [over 2 years ago]
  • V208: Andrew Hunt [over 3 years ago]
  • V201: Greg Stearns [almost 4 years ago]
  • V200: Greg Stearns [almost 4 years ago]
  • V190: Sam Ruby [about 4 years ago]