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 a suitably modified Edition 3 scenario (as well as a developing Edition 4 scenario) under various versions of Rails and Ruby is available online. 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 make it out to beta.
4.1 Creating a New Application
- Page 36/45 : After
cd demoand beforeruby script/server, editconfig/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.erbandedit.html.erbfiles, 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 wordraw.
7.1 Creating the Catalog Listing
- 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
hbeforeproduct.title, addrawbeforeproduct.description
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/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)
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:noticeparameter on theformat.htmlcall. - Page 160/166: The form can now be found in
app/views/users/_form.html.erb
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
13.1 Iteration I1: Enabling Translation
- Page 187/193: omit the setting of
LOCALES_DIRECTORY(alternately, useRails.rootinstead of RAILS_ROOT). - Page 190/196: application.rb is now application_controller.rb
- Page 199/205: delete the line containing
activerecord:fromconfig/locales/es.yml, and unindent the definition of errors.template and errors.messages - Page 200/205: error messages are double escaped. Bug 2409
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, but only with Rails version 2.3.4. Bug 3198
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 ofconfig/routes.rb. After this is done, you can remove the setup method entirely fromRoutingTestas 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/563: the line that starts with
template.locals.eachnow looks as follows:local_assigns.each do |key, value|
25.1 Sending E-mail
- Page 611/613 :
confirm.erbcan now be found inconfirm.text.erb - Page 612/614 :
order_mailer.rbcan now be found in theapp/mailerdirectory (this change also applies to the next page)_line_item.erbshould now be named_line_item.text.erb
- Page 614/616 :
sent.erbshould now be namedsent.html.erb. Additionally, remove thesent.text.erbthat was generated.- change
render(:partial => "html_line_item"torender(: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/functionaldirectory) - test/fixtures/order_mailer/sent
- test/fixtures/order_mailer/confirm
- test/unit/order_mailer_test.rb (to be placed in the
26.2 Show Me the Code!
- Page 626/628 : After
cd depot_client, editconfig/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 }
