Errata


Print Print Icon

Submit your own errata for this product.


The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.


Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question



Version Location Description Submitted By Corrected
Safari Books Online Sec.2.5
2nd Paragraph

As printed:

... without turning "this is <b>bold</b>" into "this is <b>bold</b>."

should be

... without turning "this is <b>bold</b>" into "this is <b>bold</b>."

I was reading the safari version, so this may be an example of an HTML transcription error.

Note from the Author or Editor:
I think this a case of the Safari conversion not quite working. The original on page 25 in the printed version looks fine.

Anonymous 
Safari Books Online ~140
After chapter 8

Using the code from the code repository, or the version I'd built up from the beginning of the book, when editing, or creating a new person, all the fields are labelled 'Label'.

Note from the Author or Editor:
In this case, the recommendation of the note on 137 appears to have become mandatory.

Please replace (in DocBook) from the private on 136 to the end of the note on 137 with:

<programlisting format="linespecific" id="I_programlisting8_d1e11062">private

def label_for(method, options={})
label(options.delete(:label) || method) + "&lt;br /&gt;"
end</programlisting>

<para>The <literal moreinfo="none">label</literal> method is the same
as usual and is concatenated to a <literal moreinfo="none">&lt;br
/&gt;</literal> tag, but there’s something tricky going on in the
arguments:</para>

<programlisting format="linespecific" id="I_programlisting8_d1e11073">(:label || method)</programlisting>

<para>This looks for an option named <literal moreinfo="none">:label</literal>, letting you specify label text for
the field through a <literal moreinfo="none">:label</literal>
parameter. Accessing the <literal moreinfo="none">:label</literal> value
through <literal moreinfo="none">delete</literal> <indexterm id="I_indexterm8_d1e11113" significance="normal">
<primary>delete method</primary>

<secondary sortas="label parameter with">:label parameter
with</secondary>
</indexterm>seems strange, but <literal moreinfo="none">delete</literal> does two things: it removes the
<literal moreinfo="none">:label</literal> parameter from the
<literal moreinfo="none">options</literal> array, which will keep it
from passing through to the <literal moreinfo="none">super</literal>
call, and it also returns the <literal moreinfo="none">:label</literal> parameter’s value, if there is
one. (This was optional in Rails 2.1, but appears to be mandatory in Rails 2.2 and later.) If there isn’t a <literal moreinfo="none">:label</literal>,
the <literal moreinfo="none">||</literal> <indexterm id="I_indexterm8_d1e11089" significance="normal">
<primary sortas="@pipe@pipe">|| syntax</primary>
</indexterm>will fall through to <literal moreinfo="none">method</literal>, which will create a label with the
default—the internal name of the field.</para>

Carey Barnett 
Safari Books Online Section 4.3.2.1
Following Example 4-6

... "!@name.blank? will test for both nil values and blank entries. (blank is a Ruby method of String objects." ...

The #blank? method is actually a Rails (ActiveSupport) extension applied to several classes in /core_ext/blank.rb. See also http://api.rubyonrails.org/classes/Object.html.

Note from the Author or Editor:
On page 51, para below Example 4-6, replace "blank is a Ruby method of" with "blank is a Rails method extending Ruby's "

Anonymous 
Safari Books Online 6.2
Just after Example 6-2

The author writes that "Most of this should be familiar, as even the simple model had a form_for, a label, and a text_field."

However, this is the first time that form_for shows up in the text: it is true that the scaffolding generated it, but it was neither referenced to, nor explained, earlier.

It would be nice to see an explanation of what form_for does.

Note from the Author or Editor:
Nice catch!

On page 84, please bold line 5 of Example 6-2, the form_for line.

Delete "Most of this should be familiar, as even the simple model had a form_for, a label, and a text_field."

Then delete ", though" from the following sentence.

Then insert this before "The :description" -
-----------------
The form_for method sets up an f variable that the other methods here will rely on for context, and is described in depth in the next section.
-----------------

(The "f" in "f variable should be constant-width, as should form_for.)

Michael Rogers 
Safari Books Online 6.8
towards the bottom

When you're describing the parameters date_select can accept, you list :include_seconds and its description twice.

Note from the Author or Editor:
This is correct, and appears on page 98 of the print edition. Please delete the second entry for :include_seconds, which is right above the tip. And please delete the tip as well - the "Chapter 17" it refers to is incorrect.

Mike Ottinger 
Printed Page 31
First code sample

In describing how to pass parameters to the stylesheet_link_tag, the following is written:

<%= stylesheet_link_tag :media => "all", :type => "text/css", :href => "/stylesheets/hello.css" %>

When the page is reloaded in the browser, the style does not take. This is confirmed by the lack of a link tag for the style sheet in the browser's source code window.

I tried this instead:

<%= stylesheet_link_tag 'hello', :media => "all", :type => "text/css", :href => "/stylesheets/hello.css" %>

Later on the page, in the fourth paragraph, it mentions that providing an href parameter overrides the first, unnamed parameter. I assume this to mean the missing 'hello' but that does not appear to be the case.

I tested this in both Safari and Firefox.

I believe this is an error in the text, but perhaps I am missing something?

Note from the Author or Editor:
On page 31, please replace the first (bold) code example with:

<%= stylesheet_link_tag 'hello', :media => "all", :type => "text/css", :href => "/stylesheets/hello.css" %>

Anonymous 
Printed Page 32
Example 3-3

The href parameter in the stylesheet_link_tag statement should be "/stylesheets/hello.css" not just "/stylesheets/"

Note from the Author or Editor:
In line 4 of Example 3-3, please change:

:href => "/stylesheets/"

to:

:href => "/stylesheets/hello.css"

Mike Smith 
Safari Books Online 32
Unsure as I am reading via Safari Library

"replace the old app/views/hello/index.rhtml"

should read:

"replace the old app/views/hello/index.html.erb"

Note from the Author or Editor:
This appears on page 33 on the printed edition in the second text paragraph.

Please change:

"replace the old app/views/hello/index.rhtml"

to:

"replace the old app/views/hello/index.html.erb"

Wil Harper 
Printed Page 37
second paragraph

"The structure created by the <% content_for(:name) do %> code in Example 3-9" should read "The structure created by the <% content_for(:list) do %> code in Example 3-9."

Note from the Author or Editor:
This is correct - please do as suggested:

The structure created by the <% content_for(:name) do %> code in Example 3-9" should read "The structure created by the <% content_for(:list) do %> code in Example 3-9."

sean kearney 
Printed Page 37
Example 3-10 caption

The caption for Example 3-10 says "Template with added yield...." Shouldn't the word "Template" be replaced with "Layout"?

I realize it's a minor issue, but in the 3rd paragraph it mentions the "layout" in Example 3-10, and you are talking about Template Data (the view) being shared with the layout.


Note from the Author or Editor:
On page 37, in the caption for Example 3-10, replace "Template with added yield" with "Layout template with added yield"

Leland Irwin 
Printed Page 42
line 2

It says:

"create app/views/entry"

in the commands output. However we created an entries controller. Therefore it should say:

"create app/views/entries"

Note from the Author or Editor:
This is correct. Please change line 2 on page 42 to "create app/views/entries". Also change app/views/entry in the paragraph above the note to /app/views/entries.

Brendan Nolan 
Printed Page 43
last paragraph

Implementing the book's example in Heroku Garden, I got this error when I went to http://myapp.herokugarden.com/entries/sign_in :

Routing Error
No route matches "/entries/sign_in" with {:method=>:get}

I fixed the problem by inserting this line into config/routes.rb :

map.connect ':controller/:action'

Unless I'm missing something, you might want to alert readers about this.

(BTW if you would show date stamps on the errata, that would let me know which ones are new since the last time I wrote them into my copy of the book.)

Note from the Author or Editor:
This appears to be a bug that came into Heroku (then Heroku Garden) after the book was published.

However, as Heroku Garden closed, and none of this functionality is available any longer, I'm afraid there isn't much we can do.

Mark Latham 
Printed Page 43
24th line down

This is not really a mistake per se...so much as perhaps needing more details. Since Mark Latham also posted about this I will put my .02 cents in.

This example fails to work and gives you this error:

Routing Error
No route matches "/entries/sign_in" with {:method=>:get}

if you do not start the server. There should maybe be a step explicitly explaining starting and stopping servers. It would help if there were a few lines explaining to stop the "hello" server and start the "guestbook" server (or just leave the "hello" server running and run two servers).

This may trip up some users, particularly if you read these chapters all in a row without stopping.

Note from the Author or Editor:
This appears to be a bug that came into Heroku (then Heroku Garden) after the book was published.

However, as Heroku Garden closed, and none of this functionality is available any longer, I'm afraid there isn't much we can do.

Brendan Nolan 
Printed Page 43
Example 4-2

The tag 'visitor_name' used in the book and the codeDirectFromBook does not match the tag 'visitorName' used in the code samples in ch04/guestbook001/app

Note from the Author or Editor:
The code samples should reflect the usage in the book, which is more Rubyish. I'll update the code sample.

Tom Peel 
Printed Page 45
2nd paragraph

The second paragraph on page 45 refers to the 'entry' controller, but the script/generate command used on page 41 created an 'entries' controller and figure 4-3 on the same page shows the controller as being 'entries'.

Another reference to 'entry' is in the 3rd paragraph, first sentence on page 45.

Note from the Author or Editor:
On page 45, at line 3 of paragraph 2, and line 1 of paragraph 3, please replace entry with entries.

Leland Irwin 
Printed Page 48
5th paragraph

text reads "Both of these operate on a table called People [...]" Shouldn't it read "Both of these operate on a table called Entries [...]"

Note from the Author or Editor:
Please replace "People" with "Entries". Somehow this slipped through.

Anonymous 
Printed Page 50
Paragraph beginning with "The first step creates..."

"People table" should be "Entry table" [similar to previously submitted errata on Page 48, 5th paragraph].

Note from the Author or Editor:
"People table" should change to "Entry table" as described.

sean kearney 
Printed Page 51
2nd paragraph

"People table" should be "Entries table" [similar to previously submitted errata on pages 48 and 50].

Note from the Author or Editor:
Please change "People table" in the second text paragraph of page 51 to "Entries table".

Mark Latham 
Printed Page 60
warning/caution paragraph

text reads "[...] the problem is likely that you're starting in the same guestbook application described in the previous chapter, and the Person model there is blocking the creation of the Person model here."

The previous chapter, Chapter 4, features an Entry model, not a Person model, so there shouldn't be a conflict at all.

Note from the Author or Editor:
Entire warning should be deleted. This is what we get for changing examples.

Anonymous 
Printed Page 69
Figure 5-6

The figure makes reference to 'students' even though in this chapter you've been referring to the 'people' controller (see Example 5-1 on page 66).

Note from the Author or Editor:
ouch. This is correct. In Figure 5-6, in the left-most column, please replace every instance of '/students' with '/people'.

In the ovals, replace 'students' with 'people' and 'student' with person.

There are lots of these.

Leland Irwin 
PDF Page 77
first line

CRUD doesn't really map to CREATE, SELECT, UPDATE, and DELETE in SQL terms.

CREATE should be INSERT

"you've worked with SQL, you're already familiar with INSERT, SELECT, UPDATE, and DELETE"

Note from the Author or Editor:
This is correct - I'm not sure quite what I was thinking, or not thinking, at the time. It's definitely INSERT.

On page 65 of the printed book, in the 4th paragraph from the bottom, near the end of the third line, "CREATE, SELECT," should be "INSERT, SELECT,"

Andy Gaskell 
Printed Page 82
2nd and 3rd lines

Instead of:

"accepting only the values of 0 and 1, equal to true and false"

I would find it clearer to say:

"accepting only the values of 1 and 0, equal to true and false"

or:

"accepting only the values of 0 and 1, equal to false and true"

especially since this mapping is not an invariable standard (e.g. see http://en.wikipedia.org/wiki/Boolean_datatype#Ruby).

Note from the Author or Editor:
On page 82, lines 2 and 3, please replace:

"accepting only the values of 0 and 1, equal to true and false"

with:

"accepting only the values of 1 and 0, equal to true and false"

Mark Latham 
Printed Page 84
Example 6-2

I understand the book was written using rails 2.1; I am using rails 2.2.2.

When I open new.html.erb in example 6-2, it displays the following:

<h1>New person</h1>

<% form_for(@person) do |f| %>
<%= f.error_messages %> ...

The book shows the following:

<h1>New person</h1>

<%= error_messages_for :person %>

<% form_for(@person) do |f| %> ...

Did the scaffold output change in the most recent rails update?

Note from the Author or Editor:
This is correct - Rails 2.2.2 changed the scaffolding. It sounds like more changes will be coming with 2.3 as well.

<%= error_messages_for :person %>

should become:

<%= f.error_messages %>

Anonymous 
Printed Page 87
Last sentence

The author writes: "Underneath, form_for is pretty much a form-specific version of the link_to method shown in Chapter 2. Like link_to, it understands Rails' routing and will choose its attributes based on that routing."

I don't recall being introduced to a link_to method in Chapter 2. I double checked the index to see if I overlooked link_to, but the first mention of that method is mentioned on page 160.

Note from the Author or Editor:
This is correct. I'll have to add more detail in a future revision.

E.M. Brown 
PDF Page 97
First paragraph

The generated code for favorite time:

<p>
<b>Favorite time</b><br />
<%= f.datetime_select :favorite_time %>
</p>

Keeps causing the saved time to be something like this:

Sat Jan 01 01:53:00 UTC 2000

No matter what I pick, that's what I get.

Note from the Author or Editor:
The place to fix this is actually on page 83. In the bold script/generate scaffold command near the top, change favorite_time:time to favorite_time:datetime.

In a future edition I'll need to explain time and datetime, but recent versions of Rails seem to treat time as a datetime with the date permanently set to 1/1/2000. Earlier versions just treated it as a datetime.

Eric Gruber 
Printed Page 100
Example 6-6

The code to call the 'buttons' helper method reads buttons(:person, nations), but it should read buttons(:person, :country, nations). Please note that the code on the excursionsonrails.com website doesn't feature the view code _or_ the helper code at all.

Note from the Author or Editor:
In the book, the bold text in Example 6-6 should change from:

buttons(:person, nations)

to:

buttons(:person, :country, nations)

Also, on page 102 - in Example 6-8, in the line immediately after "return html", there's an extraneous "end". Please delete it.

I'll update the sample code to include these.

Anonymous 
Printed Page 114
2nd paragraph

The word 'password' should be 'secret' since that is what is being validated.

Note from the Author or Editor:
On 114, 2nd paragraph, please replace "if a user enters a password" with "if a user enters a secret".

Leland Irwin 
Printed Page 117
2nd paragraph

For the 'validates_uniqueness_of' options, there should be a comma after ':scope => [:name, :secret]'.

Note from the Author or Editor:
This is correct. Please add a comma after :scope => [:name, :secret]

Ray Drainville 
Printed Page 124
last code example on page

Rails 2.2.2 seems to have changed how it handles the _path helper methods. As a result, when the @person object has nil fields, the person_path(@person) method doesn't work, and you can't get a form for creating a new person. (For more, see http://forums.oreilly.com/content/Learning-Rails/929/Routing-Error-Chapter-8/)

Note from the Author or Editor:
Please replace:

:url => person_path(@person),

with:

:url => { :action => ( @person.new_record? ? "create" : "update" ) },

Thanks!

Simon St. Laurent
Simon St. Laurent
O'Reilly AuthorO'Reilly Blogger 
Printed Page 134
Example 8-2

There seems to be nothing in the text that suggests that Example 8-2 should be named "tidy_form_builder.rb". Of course, the class name is a clue, and there is a reference to the sample code, but most of the previous additions to the example rails application are quite specific about the file(s) to which code is to be added and/or what files need to be created.

Note from the Author or Editor:
The caption to Example 8-2 should be modified to say "A form builder, stored in app/helpers/tidy_form_builder.rb, providing a method more tightly bound to the expectations of the country field."

Also, on page 135, the first line under the first code piece should say "Rails will know to look for /app/helpers/tidy_form_builder.rb."

Anonymous 
Printed Page 134
2nd paragraph

The text mentions that Rails has its own country_select, but the method is deprecated since 2.2, and is now only available as a plugin.

Note from the Author or Editor:
Please change:

(Rails has its own

to:

(Prior to version 2.2, Rails had its own

Tom Peel 
Printed Page 147
2nd paragraph, 4th line

"belong_to" should be "belongs_to"

Note from the Author or Editor:
On page 147, 2nd paragraph, 4th line, please change belong_to to belongs_to. This also affects an index entry.

Mark Latham 
Safari Books Online 149
8.2.2. Adding Automation - last two paragraphs

On the last two paragraphs, it says:

here's one last bit to notice. Remember how country_select calls the select method? It now calls the method that provides the label. That means that you can simplify:

<p>
<%= f.label :country %><br />
<%= f.country_select :country %>
</p>

to:

<p>
<%= f.country_select :country %>
</p>

If you follow up the instructions up to this point, this will not work is, as the step for adding select method was apparently missing (although it does appear in the code examples). So before this paragraph, should this be added:

def select(method, choices, options = {}, html_options = {})
label_for(method, options) + super(method, choices, options, html_options)
end


Note from the Author or Editor:
This is on 137 of the printed book.

In the second section of code (beginning with def datetime_select), please append:

def select(method, choices, options = {}, html_options = {})
label_for(method, options) + super(method, choices, options, html_options)
end

to the end.

Rilindo Foster 
Printed Page 149
validates_existence_of at top of page

I feel you should let the reader know that they should restart the server as I got:
NoMethodError (undefined method `validates_existence_of' for #<Class:0x23d0e08>):
app/models/award.rb:7
app/controllers/awards_controller.rb:5:in `index'
in the logs until I restarted.

Note from the Author or Editor:
Please change "Now, if you try to save an award record" to "Now, if you restart the server and try to save an award record"

Rob Levin 
Printed Page 149
3rd paragraph

The third paragraph states:

"and add this line underneath the belongs_to declaration of app/models/awards.rb:"

The file name should be "award.rb" not "awards.rb."

Note from the Author or Editor:
Please change awards.rb to award.rb.

R.N. 
PDF Page 160
3rd paragraph

There is no reference to Ch08/guestbook009. The text skips from 008 to 010.

Note from the Author or Editor:
This is correct, but it doesn't actually cause problems. I'll fix it in a future edition.

Rick Nobleman 
Printed Page 162
5th paragraph down.

Refers to figure b-3 of appendix B. I think this should probably be b-5 as that clearly is a join table.

Note from the Author or Editor:
This is correct. Please replace "Figure B-3" with "Figure B-5".

Rob Levin 
Printed Page 171
First line in top of the page

Instead of double quotes it should be single quotes in the <%= submit_tag 'Remove checked courses' %>.

It cause me problem by unprocessing my «course_remove_student_path(@student)» url request

Note from the Author or Editor:
The quotes really shouldn't matter. Double quotes make it a string that allows substitution, but there isn't any here.

However, single quotes are better practice in any event, so please change <%= submit tag "Remove checked courses" %> to <%= submit tag 'Remove checked courses' %>.

Anonymous 
Printed Page 225
middle of page

"the third name stores that name" should be:
"the third line stores that name"

(Also, changing from 'visitor_name' in Examples 4-2 & 4-3 to 'visitorName' in Examples 13-1 & 13-2 was a bit distracting, since I copied & pasted some code.)

Note from the Author or Editor:
All on page 225:

in Example 13-1, line 4: replace :visitorName with :visitor_name.

fourth line, first para after 13-1: replace :visitorName with :visitor_name. Then replace "the third name stores that name" with "the third line stores that name".

in Example 13-2, line 5: replace 'visitorName' with 'visitor_name'.

Mark Latham 
Printed Page 225
Example 13-2

On the user's first visit, with no cookie named "name", this condition:

<% if @previous_name != '' %>

is true because nil is not the same as blank (at least in Heroku Garden; not sure about other environments).

So user sees the message:
"Hmmm... the last time you were here, you said you were ."

Here's one way to fix it:

<% if !@previous_name.nil? and @previous_name != '' %>

Note from the Author or Editor:
On page 225, Example 13-2, please replace:

<% if @previous_name != '' %>

with:

<% unless @previous_name.blank? %>

Mark Latham 
Printed Page 234
Last paragraph

After rake db:sessions:create, two more steps needed to make SessionStore work:

rake db:migrate

uncomment secret in controllers/application.rb

Note from the Author or Editor:
Please change:

database support for session storage.

to:

database support for session storage, and should then also run <literal moreinfo="none">db:migrate</literal>. You'll also need to edit the <filename moreinfo="none">app/controllers/application.rb</filename> file to uncomment the <literal moreinfo="none">:secret</literal>.

Mark Latham 
PDF Page 260
Globbing

"accessible through the :specs parameter"

Shouldn't :specs be :steps?

Note from the Author or Editor:
Yes indeed! In the paragraph in the middle of the page, starting with "The asterisk" please change :specs in the second line to :steps.

emnaki 
Printed Page 278
End of 3rd paragraph

Says:

Note from the Author or Editor:
Replace "In both controllers, course_add and course_remove, the old concluding line:" with "In both the Student controller's actions course_add and course_remove, the old concluding line:"

Rob Levin 
Printed Page 279
First indendted bullet point 2/3 down the page

page << "alert("I entered this code myself")
inconsistent quotation marks and no closing quote for the whole alert. This worked:
page << "alert('I entered this code myself')"

Note from the Author or Editor:
Please change page << "alert("I entered this code myself") to page << "alert('I entered this code myself')"

Rob Levin 
Printed Page 319
Figure 18-4

Figure 18-4 should show an empty list of students (instead of the listing with student 'Dylan Wonkatoni Chazwick').

Note from the Author or Editor:
This is correct, and I'll need to submit a new figure. I'd originally meant to show more of the application running, and apparently deleted the wrong figure.

K.Oster 
Printed Page 333
Paragraph under Variables, Methods, and Attributes

on line 3, where it says "and visit http://localhost:3000/testbed/", it should make clear that you also need to add 'testbed' to the end of whatever URL Heroku gives you after you press the >> button.

Note from the Author or Editor:
Please add a sentence after "a mostly blank response." that says:

(In Heroku Garden, you may need to add 'testbed' right after the URL that Heroku Garden sends you to when you've pressed >>.)

Simon St. Laurent
Simon St. Laurent
O'Reilly AuthorO'Reilly Blogger 
Printed Page 337
2nd paragraph

At start of 2nd paragraph: "When index is called, is sets..." should be "When index is called, it sets..."

Note from the Author or Editor:
Correct. Please change "When index is called, is sets" to "When index is called, it sets" .

Jonathan Hironaga 
Printed Page 341
list of operators

**:

Note from the Author or Editor:
Please change "less then yields" to "less than yields" and "10**4 is 1000" to "10**4 is 10000"

j hiro 
Printed Page 346
at the bottom of the page

def index
my_array = [5,4,3,2,1]
@result = ''
for i in *myArray*
@result = @result + i.to_s + ""
end
end

The myArray variable should be my_array.

Note from the Author or Editor:
This is correct. Please change myArray to my_array.

(For consistency, please make that change throughout the appendix.)

Anonymous 
Printed Page 352
2nd paragraph, 5th line

Note from the Author or Editor:
Please change "managed related" to "manage related".

j hiro 
Printed Page 359
code after 3rd paragraph

sentence =~ /Ruby/
# => 2 - There are two instances of

Note from the Author or Editor:
Please change '# => 2 - There are two instances of "Ruby".' to:

# => 0 - The first instance of 'Ruby' appears at position 0.

j hiro