Page 17:
Replace
The configuration file, database.yml, is located in the db folder
with
The configuration file, database.yml, is located in the config folder
Page 27:
Replace
Options 1 and 2 are self-explanatory.
with
Options 1 and 3 are self-explanatory.
Page 49:
assert_tag with the content option doesn’t work with partial matches anymore. Either regexps (e.g. /#{a.first_name}/) or (better) assert_select (since assert_tag is now deprecated in favor of the latter) should be used instead.
Page 50:
Add the following inside the code listing after ” last_name: Keith ” (the end of the page, please keep the indentation similar to that of the existing lines) (this will be needed for the test on page 82 to work):
christian_hellsten:
id: 3
first_name: Christian
last_name: Hellsten
jarkko_laine:
id: 4
first_name: Jarkko
last_name: Laine
Page 51:
Right after
Now we can rest assured that when we start testing viewing an author, we have two items in our authors table.
add the following (in the same paragraph):
If you want to use the same fixture data in your development environment, run rake db:fixtures:load to load the fixtures in the development database.
Page 80:
Replace
validates_format_of :isbn, :with => /[0-9\-xX]{13}/
with
validates_format_of :isbn, :with => /[0-9\-a-zA-Z]{13}/
Page 82:
Replace
When you run the test, there is a validation failure on each of the fields—eight in total.
with
When you run the test, there is a validation failure on each of the fields—seven in total.
Page 84:
Replace
:title => 'Rails E-Commerce 3nd Edition',
with
:title => 'Rails E-Commerce 3rd Edition',
Page 85:
Replace
$ tail -f logs/test.log
with
$ tail -f log/test.log
Page 86:
Replace
pro_rails_ecommerce_1:
author_id: 1
book_id: 1
pro_rails_ecommerce_2:
author_id: 2
book_id: 1
with
pro_rails_ecommerce_1:
author_id: 3
book_id: 1
pro_rails_ecommerce_2:
author_id: 4
book_id: 1
Page 98:
Replace
<p><label for="book_price">Page count</label><br/>
with
<p><label for="book_page_count">Page count</label><br/>
Page 101:
Add the following note after “multiple-selection list are displayed on the screen.” :
Note There is a bug in the current Rails code that causes assert_tag fail on subsequent requests inside a single test method. See http://dev.rubyonrails.org/ticket/6834 for details on how to avoid this. The bug will be fixed in version 1.2.
Page 109:
Replace
$ test/integration/book_test.rb
with
$ ruby test/integration/book_test.rb
Page 112:
Replace
Again, run the tests with rake test:integrations.
with
Again, run the tests with rake test:integration.
Page 119:
Replace
map.connect ", :controller => "catalog"
with
map.connect '', :controller => "catalog"
(replace the double quote after .connect with two single quotes)
Page 120:
Replace
:content => "by #{@book.authors.map{|a| a.name}}"
with
:content => "by #{@book.authors.map{|a| a.name}.join(", ")}"
Pages 125-131
The API of acts_as_ferret has changed. Replace all occurrences of Book.find_by_contents with Book.find_with_ferret.
Page 132:
Replace
with
Page 142:
Add the following to the end of the page:
You also need to load the needed fixtures for the tests:
fixtures :authors, :publishers, :books, :authors_books
Page 148:
Replace
sum =+ item.price * item.amount
with
sum += item.price * item.amount
Page 158:
Replace
<dt><%= link_to book.title.t, :action => "show", :id => book %></dt>
with
<dt><%= link_to book.title, :action => "show", :id => book %></dt>
Replace
<dd><small><%= 'Publisher'.t %>: <%= book.publisher.name %></small></dd>
with
<dd><small><%= 'Publisher' %>: <%= book.publisher.name %></small></dd>
Replace
the following at the bottom of public/javascripts/style.css:
with
the following at the bottom of public/stylesheets/style.css:
Page 164:
Replace
page.replace_html "cart_total", "<strong>Total: $#{@cart.total}</strong>"
with
page.replace_html "cart_total", "<strong>Total: $#{sprintf("%0.2f", @cart.total)}</strong>"
Page 167:
Replace
<p id="cart_total"><strong>Total: $<%= @cart.total %></strong></p>
with
<p id="cart_total"><strong>Total: $<%= sprintf("%0.2f", @cart.total) %> ?
</strong></p>
Page 172:
Figure 6-1 is empty and should look like this:

Page 173:
Replace
create db/migrate/005_create_forum_posts.rb
with
create db/migrate/007_create_forum_posts.rb
Page 175:
Replace
too long, which is why it is limited to between 5 and 250 characters.
with
too long, which is why it is limited to between 5 and 255 characters.
Page 188:
Replace
#{post.created_at.strftime("%H:%M:%S %Y-%M-%d") }
with
#{post.created_at.strftime("%H:%M:%S %Y-%m-%d") }
Page 191:
Replace
<%= link_to 'Back', :action => 'list' %>
with
<%= link_to 'Back', :action => 'index' %>
Page 192:
In figure 6-5, the back link is missing.
Page 199:
Remove the following paragraph:
The location of the repository depends on your system and RubyGems configuration. On our machine, the gem was installed in /usr/lib/ruby/gems/1.8/gems/acts_as_taggable-2.0.2/.
Page 201:
Replace
create db/migrate/006_create_tags_and_books_tags.rb
with
create db/migrate/008_create_tags_and_books_tags.rb
Page 207:
Replace
George entering the tags Elvis, Thriller, and Cooking in the Tags field.
with
George entering the tags Ruby, Programming, and Dummies in the Tags field.
Page 209:
Replace
Fix this by changing the load method
with
Fix this by changing the load_data method
Page 213:
Replace
Next, change the edit action in app/controllers/admin/book_controller.rb as follows:
with
Next, change the update action in app/controllers/admin/book_controller.rb as follows:
Page 215:
Replace
The Show Tag user story describes how customers should be able to view all tags in the system.
with
The List Tags and Show Tag user stories describe how customers should be able to view all tags in the system.
Page 215:
Remove the following text and combine the paragraphs that are left of the two:
Before we continue with the next user story implementation, George reminds us that he expects us to complete the three remaining user stories today: “I have friends in Bangalore! I’ll just offshore the whole project to India, if you can’t get it done today.” To speed up development, we’ll use the generate script to create a new controller.
Page 216:
Add the missing period after the following:
as we’ll show you next
Page 216:
Replace
Next, add the following code to app/views/admin/books/list.rhtml:
with
Next, add the following code to app/views/tag/list.rhtml:
Page 226:
Replace
$ rake migrate
with
$ rake db:migrate
Page 234:
Replace
assert_equal "Incorrect login!", flash[:notice]
with
assert_tag :tag => 'div',
:attributes => { :id => 'notice' },
:content => 'Incorrect login!'
Page 236:
Replace ‘index’) flash[:notice] = “Logged in successfully” end flash.now[:notice] = “Incorrect login!”
if logged_in?
#
redirect_back_or_default(:controller => '/account', :action =>
with ‘index’) flash[:notice] = “Logged in successfully” else flash.now[:notice] = “Incorrect login!” end
if logged_in?
#
redirect_back_or_default(:controller => '/account', :action =>
Page 237:
Replace
<% if current_user %>
with
<% if logged_in? %>
Page 238:
Before this:
Now the login status box appears in the top-right corner of the page, as shown in Figure 8-3.
Add this:
Before you can test the functionality in browser, you have to create a user for yourself. Since we don’t have an administration interface for users, the easiest way to create a user is by using the console:
$ script/console
Loading development environment.
>> User.find :all
=> []
>> User.create(:login => "george", :email => "george@emporium.com",
:password => "georgie", :password_confirmation => "georgie")
=> #<User:0x298d880 @errors=#<ActiveRecord::Errors:0x2980f2c @errors={},
@base=#>, @password="georgie",
@attributes={"salt"=>"453d4741ca43a59243f9cd315cdfa1c630a0428e",
"updated_at"=>Sat Dec 30 10:09:30 EET 2006,
"crypted_password"=>"51a3e693034fd7c22118548785426aa95c4e2ac8",
"remember_token_expires_at"=>nil, "id"=>1, "remember_token"=>nil,
"login"=>"george", "pw_reset_code"=>nil, "created_at"=>Sat Dec 30 10:09:30 EET 2006,
"email"=>"george@emporium.com"}, @new_record=false,
@password_confirmation="georgie">
Note that you also have to give the password confirmation, otherwise the user object will not validate.
Page 242:
Replace
update_attributes(:password_reset_code => nil)
with
update_attributes(:pw_reset_code => nil)
Page 258:
Add after
The credit card fields are validated only on create, as they don’t exist in the database.
the following:
Since we are validating that the status of an order is always “open”, “processed”, “closed” or “failed”, the validation will fail if the status is empty. Therefore we should set it automatically when a new order is created. We can do it by adding the following filter to the Order class:
class Order < ActiveRecord::Base
before_validation :set_status
end
...
protected
def set_status
self.status = "open" if self.status.blank?
end
...
The filter checks whether the status is already set before any validations are run, and if not, it sets the status to “open”.
Page 258:
Replace
We should also take care that the amount and price are correct,
with
We should also take care that the amount and price are correct for each order item,
Page 258:
Replace
assert_equal 15, order.errors.size
with
assert_equal 16, order.errors.size
Page 259:
$ script/generate integration checkout
should be:
$ script/generate integration_test checkout
In the latest Rails versions.
Page 267:
The “Proceed to checkout” link should not be in figure 9-3.
Page 269
:card_verification_value => '333',
There should be no comma after the last hash element.
Page 270:
Replace
The following code for the process method should be added to the Order model
with
The following code for the process method should be added to the public section of the Order model
and then remove the line
private
from the code right below.
Page 279:
Replace
http://rails.techno-weenie.net/tip/2006/6/5/country_select_with_country_codes.
with
http://www.railsweenie.com/forums/2/topics/756.
Page 291
Replace
$<%= item.price * item.amount %>
with
$<%= item.price * item.amount %>