Product Overview

Hooray! A new and improved edition on this book is now available!

The 1st edition of Build Your Own Ruby on Rails Web Applications was a fine book but we replaced it with a new and updated edition in May 2008.

However, if you do happen to own a copy of 'Build Your Own Ruby on Rails Web Applications - 1st edition' you may still be interested in:

Build Your Own Ruby on Rails Web Applications

Corrections & Typos

Found a mistake that’s not listed here? Contact us to let us know!

Confirmed typos in the September 2007 update:

Some of the errors listed here may also apply to the previous edition (see below).

  • p.19, footnote

    Locomotive is no longer being maintained by it's author.

  • p.38, 4th code listing

    The command should be: bin/mysqld_safe --user=mysql &

  • p.70, 1st paragraph

    Class variables don't work this way in Ruby; a subclass shares its class variables with its parent class so all cars will now have 6 wheels. Use a class constant instead: WHEELS instead of @@wheels.

  • p.227, 1st paragraph

    The filename mentioned should be story_controller_test.rb.

  • p.230, 3rd code listing

    The code should read:
    assert_redirected_to :action => 'show',:permalink => 'sitepoint-forums'

  • p.313, last code listing & code archive

    The code is missing an end from the test_should_generate_permalink test in 29-story_test.rb

  • chap 9, code archive

    The is a missing last line:
    <%= render :partial => 'story', :collection => @stories %>
    in the file 12-index.rhtml

  • p.326, last paragraph

    The acts_as_taggable plugin install command should now be:
    ruby script/plugin install http://svn.rubyonrails.org/rails/plugins/legacy/acts_as_taggable/

  • p.336, 2nd code listing

    The code should read:
    <% if @story.tags.size.nonzero? %>

Confirmed typos in the March 2007 update:

Some of the errors listed here may also apply to the previous edition (see below).

  • p.16, warning

    The warning Watch your version numbers! advises not to install Ruby 1.8.5 due to the incompatibility with the breakpointer tool. As this tool is now deprecated, we recommend readers go ahead and install the latest version of Ruby (currently version 1.8.5) as recommended by the Rails core team.

  • p.17, footnote

    The footnote advises Windows users install InstantRails 1.3a to remain compatible with the breakpointer tool. As this tool is now deprecated we recommend readers install the latest InstantRails package that contains Rails 1.2 — currently InstantRails 1.7.

  • p.20, 3rd paragraph

    The paragraph advises Mac OS X users not to use the MacPorts package, in order to remain compatible with the breakpointer tool. As this tool is now deprecated, readers comfortable with using MacPorts to install packages should feel free to use it to install the latest version of Ruby (current 1.8.5).

  • p.38, 3rd code listing

    chgrp -R mysql should read chgrp -R mysql . (note the period at the end)

  • p.78, 5th code listing

    An open curly brace is missing from the hash definition. It should read:

    car_colors = {
      :kitt => 'black',
      :herbie => 'white',
      :larry => 'green',
      :batmobile => 'black'
    }
  • p.123, code listing

    The code contains an extra end. It should read:

    class CreateStories < ActiveRecord::Migration
      def self.up
        create_table :stories do |t|
          # t.column :name, :string
        end
      end
      def self.down
        drop_table :stories
      end
    end
  • p.127, note

    The command in the note titled Rolling Back is Easy, Too! should read:

    $ rake db:migrate VERSION=n
  • p.170, 2nd code listing

    The test named test_should_create_user should be named test_should_create_story.

  • p.177, 1st code listing

    The code listing is correct, however previous versions of the test in the chapter 6 code archive file 22-story_controller_test.rb contained an error, and should read:

    def test_should_show_new_form
        get :new
        assert_select 'form p', :count => 3
      end

    Readers should download the code archive again to receive the latest version of this file.

  • p.196, last code listing

    The code should read:

    add_column :stories, :permalink, :string
  • p.211, second code listing

    This should read:

    page.replace_html 'vote_score', "Score: #{@story.votes_count}"
  • p.216 third paragraph

    The code below obviously uses an if … then … else construct, not an unless … then … else construct.

  • p.226, screenshot

    The number of tests (and assertions) that your rake task should report is 7, not 8.

  • p.229, second code listing (and description on p.230)

    The code should read:

    def test_should_render_rjs_after_vote_with_ajax
      @request.env['HTTP_ACCEPT'] = 'text/javascript'
      xml_http_request :post, :vote, :id => 2
      assert_response :success
      assert_template 'vote'
    end
  • p.230, 2nd code listing

    The code listing is correct, however the chapter 7 code archive the files 33-story_controller_test.rb and 34-story_controller_test.rb files contain an error and should read:

    def test_should_redirect_after_vote_with_get
      get :vote, :id => 2
      assert_redirected_to :action => 'show',
          :permalink => 'sitepoint-forums'
    end
    Readers should download the code archive again to receive the latest version of these files.

  • p.244, 1st code listing

    The final line of code should read <% end %>, not <% end_form %>

    The 05-login.rhtml file in the chapter 8 code archive for this listing previously contained an error: remove the '=' from <%= form_tag do %> and <%= end %> so that they read <% form_tag do %> and <% end %>. Readers should download the code archive again to receive the latest version of this file.

  • p.260, 1st code listing

    The code listing is correct, however previous versions of the code in the chapter 8 code archive files 16-story_controller.rb and 18-story_controller.rb contained an error, and should read:

    before_filter :login_required, :only => :new
  • p.260, 2nd code listing

    The 4th line reads:

      session[:user_id] = @current_user.nil?

    It should instead read:

      session[:user_id] = @current_user.id
  • p.291, 1st code listing

    The SQL passed to :order is incorrect. It should read:

    :order => 'id DESC',

    The code archive contains the correct code for this file.

  • p.308, last code listing

    The code should read:

    <div id="stories_submitted">
      <h2>Stories submitted by <%= @user.name %></h2>
      <%= render :partial => 'story/story',
            :collection => @stories_submitted %>
    </div>
    <div id="stories_voted_on">
      <h2>Stories voted for by <%= @user.name %></h2>
      <%= render :partial => 'story/story',
            :collection => @stories_voted_on %>
    </div>
  • p.313, 3rd code listing

    The promoted story in the fixture data is missing a name and a link. It should read:

    promoted:
      id: 3
      name: What is a Debugger?
      link: http://en.wikipedia.org/wiki/Debugger/
      permalink: promoted-story
      user_id: 2
      votes_count: 5
  • p.316, 1st code listing

    The code listing is correct, however the previous version of the test in the chapter 9 code archive file 32-story_controller_test.rb contained an error, and should read:

    def test_should_only_list_unpromoted_in_bin
        get :bin
        assert_equal [ stories(:another), stories(:first) ],
          assigns(:stories)
      end

    The two tests from the code listing, test_should_only_list_promoted_on_index and test_should_only_list_unpromoted_in_bin were missing from the story_controller_test.rb file; readers should download the code archive again to receive the updated files.

  • p.320, first code listing

    The fifth line should read:

    get :show, :permalink => 'my-shiny-weblog'
  • p.355-359

    The breakpointer tool has been deprecated from the Rails framework, so these instructions will not work with the latest version of Ruby (currently 1.8.5). There is an alternative tool available called ruby-debug. Read more about using ruby-debug.

Confirmed typos in the January 2007 1st edition:

  • p.19, first paragraph

    The most recent version of Rails relies on a more recent version of RubyGems than the one released with InstantRails 1.3a. To update RubyGems, type the following at the command line: gem update --system

  • p.65 (2nd code listing), p.66 (1st code listing), p.67 (3rd code listing), p.80 (code listing)

    In fact, instance variables do not need declaring. The following line:

    @mileage = 0

    actually declares an instance variable at the class-level, which is redundant and should be omitted.

  • p.66, 6th paragraph

    "accessor variables" should read "accessor methods".

  • p.69, 2nd paragraph

    The sentence should read: "The method tells us that three instances of the Car class have been created."

  • p.85, 4th paragraph

    The last sentence in the paragraph should read "The first iteration has car set to the equivalent of kitt, the second iteration has it set to herbie, and so forth."

  • p.124, footnote

    Leaving :force => true in this migration will mean that Story records will be wiped with each future migration. Set true to false after you have performed this migration to prevent this.

  • p. 177, 3rd paragraph

    The assert_select assertion checks for the existence of three p elements, not five.

  • p.208, last line on the page

    The file public/stylesheets/styles.css should be public/stylesheet/style.css

  • code listings on pp.209, 253, 256, 288, 309 and 337

    styles.css should be style.css

  • p.260, 2nd code listing

    The code listing should read:

    def login
      ...
        unless @current_user.nil?
          session[:user_id] = @current_user.id
          unless session[:return_to].blank?
            redirect_to session[:return_to]
            session[:return_to] = nil
          else
            redirect_to :controller => 'story'
          end
        end
      ...
  • p.326, code listing

    The acts_as_taggable plugin has been deprecated. You can still install it, however, using the following command: $ ruby script/plugin install http://dev.rubyonrails.org/svn/rails/plugins/legacy/acts_as_taggable

  • p.350, 1st code listing

    The code should read:

    Extracted source code (around line #22):
    20: <p class="submitted_by">
    21:   Submitted by:
    22:   <span><%= link_to @story.user.login,
    23:          :controller => 'account',
    24:          :action => 'show',
    25:          :id => @story.user.login %></span>
  • p.350, 2nd code listing

    The code should read:

    22: <span><%= link_to @story.user.login,

  • p.350, 3rd code listing

    story.rhtml should be show.rhtml, and the code should read:

    …
    <p class="submitted_by">
      Submitted by:
      <%= @story.user.class %>
      <span><%# link_to @story.user.login,
          :controller => 'account',
          :action => 'show',
          :id => @story.user.login %></span>
    </p>
    …
  • p.352, 1st code listing

    story.rhtml should be show.rhtml, and the code should read:

    …
    <p class="submitted_by">
      Submitted by:
      <span><%= link_to @story.user.login, … %></span>
    </p>
    …
  • p.357, code listing

    The line of code to tag stories has been omitted. The code should read:

    def new
      @story = Story.new(params[:story])
      @story.user = @current_user
      if request.post? and @story.save
        breakpoint
        flash[:notice] = 'Story submission succeeded'
        @story.tag_with params[:tags] if params[:tags]
        redirect_to :action => 'index'
      end
    end
  • p.359, code listing

    app/views/new.rhtml should be app/views/story/new.rhtml.



Instant Download!
This title available in Adobe PDF format only

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