Product Overview
Looking for the old edition of “Simply Rails 2?”
Download the code archive or view errata of the old edition here.
Simply Rails 2
Corrections & Typos
Found a mistake that’s not listed here? Contact us to let us know!
May 2008
- console command listings
Many code listings that show console commands begin with a "$" symbol. This represents the command prompt and is not meant to be typed in. This is explained in the section called "Introducing the Command Line" on page 21 in the Mac OS X instllation section, so a lot of readers missed it.
- migration files
You may notice that your migration files are numbered differently to how they appear in the book. There was a change in Rails 2.1 to use timestamps for the file name prefix instead of the sequential numbering used in previous Rails versions. Don't worry, though, it won't cause any problems.
- p. 269 3rd paragraph
The name of the application controller file has changed as of Rails 2.3. Instead of
application.rb, in Rails 2.3 it's calledapplication_controller.rb. - p.152 last code listing
The file reference should be
14-stories_controller.rb - p.174 1st code listing
The file reference should be
10-style.css - p.229 1st code listing
The code should read:
class VotesController < ApplicationControllerinstead of:
class VotesController < ActionController::Base - p.235 code listing
In the code example
@story.votes_countshould be@story.votes.size.votes_countis added to the story model later on in the book. - p.238 2nd paragraph
The
latest_votesmethod mentioned is actually calledlatest. - p.242 code block
Running the tests at this point will fail if you are using Rails 2.3 or later. The book was written for Rails 2.0, and the way Rails generates ID values for fixtures has since changed. Since we're relying on higher ID numbers to get the most recent votes, and those IDs are no longer attributed sequentially in fixtures, the test will fail. An easy solution is to modify the fixture file (shown at the top of page 239) to manually set the id values:
one: story: one id: 1 two: story: one id: 2Alternately, you could modify the controller code to rely on created_at instead of id to find the most recent votes.
- p.269 first code listing
The file reference should be
08-application.rb - p.308 1st code listing
The code listing is missing a trailing quotation mark. It should be:
page.replace_html 'vote_score', "Score: #{@story.reload.votes.size}" - p.310 1st code listing
The code listing is missing a trailing quotation mark. It should be:
<%= "Showing #{ pluralize(@stories.size, 'story', 'stories')}"%> - p.321 2nd code listing
The code should read:
<% form_remote_tag :url => story_votes_path(@story) do %>
<%= submit_tag 'shove it' %>
<% end %> - p.322 code listing
Line 4 should read
@story = Story.find(params[:story_id]) - p.355 code block
Since publication of the book, the acts_as_taggable_on_steroids plugin has moved from using SVN to Git for version control. This means that the URL provided in the book will no longer work for installing the plugin.
To fix this, you first need to install Git, instructions for which can be found in this article.
Once you've installed Git, run this command to install the plugin (all on one line):
ruby script/plugin install http://github.com/jviney/acts_as_taggable_on_steroids.git/ --forceThe --force option is there to force the installer to overwrite the earlier failed installation, you can remove this if you haven't already tried to run the code from the book.
- p.63 1st paragraph
The sentence should read: "Ruby uses the period to separate the the receiver from the message that's being sent to it, in the form Receiver.message."
- p.30, installation instructions
On Mac OS X Leopard, if you install the latest version of sqlite3 as per the instructions at the top of the page, the command given at the bottom of the page to install the sqlite3-ruby gem will not work as written. To use the book on Leopard you do not actually have to install anything, the version of sqlite3 that comes with the OS is sufficient. But if you do, you'll need to use these alternative commands to install the gem depending on your CPU:
# Intel sudo env ARCHFLAGS="-arch i386" gem install sqlite3-ruby # Power PC sudo env ARCHFLAGS="-arch ppc" gem install sqlite3-ruby - p.102, 1st code listing
The SQL code in the book is correct, the code in the code archive is incorrect.
- p.103, terminal output
urlshould belink. - p.182, code listing
The test named
test_should_be_valid_without_linkworks fine but is poorly named. A better name would betest_should_not_be_valid_without_link. - p.191, last code listing
The example
post :new, :story...should bepost :create, :story...as it is in the previous code listing. - p.220, paragraph after code listing
:defaultsargument is mentioned incorrectly in the paragraph as:default. - p.237, 1st code listing
:partial => 'vote'should be:partial => 'votes/vote', that is, identical to the previous version. This may lead to confusion as the only change from the previous version is changing@story.votesto@story.votes.latest. - p.241, 2nd & 4th paragraph
All references to the
latest_votesmethod should be changed to thelatestmethod. - p.246, 5th paragraph
In the sentence 'The first line casts the vote with a simple HTTP GET:', 'GET' should be 'POST'.
- p.334, 2nd code listing
The code contains an erroneous closing parenthesis
). - p.344, 2nd code listing
div#vote_linkshould bediv#vote_form.
