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.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.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.182 2nd code block To be consistent in the human readable names of the tests, the test name should contain "not" just as the "name" test does. The line should read:
    
    def test_should_not_be_valid_without_link
    
    This doesn't affect the functioning of the test, but it might be confusing.
  • p.229 1st code listing

    The code should read:

    class VotesController < ApplicationController

    instead of:

    class VotesController < ActionController::Base

  • p.235 code listing

    In the code example @story.votes_count should be @story.votes.size. votes_count is added to the story model later on in the book.

  • p.238 2nd paragraph

    The latest_votes method mentioned is actually called latest.

  • 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: 2
    

    Alternately, you could modify the controller code to rely on created_at instead of id to find the most recent votes.

  • p.246 after 2nd code block The book says: "Let's examine each line in this test. The first line casts the vote with a simple HTTP GET:" This text refers to the next code excerpt, which actually contains a POST, so the according text should say: "...with a simple HTTP POST:"
  • 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 called application_controller.rb.
  • 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/
        --force

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

    url should be link.

  • p.182, code listing

    The test named test_should_be_valid_without_link works fine but is poorly named. A better name would be test_should_not_be_valid_without_link.

  • p.191, last code listing

    The example post :new, :story... should be post :create, :story... as it is in the previous code listing.

  • p.220, paragraph after code listing

    :defaults argument 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.votes to @story.votes.latest.

  • p.241, 2nd & 4th paragraph

    All references to the latest_votes method should be changed to the latest method.

  • 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_link should be div#vote_form.



Print

SitePoint Books

  • advocate best practice techniques
  • lead you through practical examples
  • provide working code for your web site
  • make learning easy and fun

100% Money Back Guarantee