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
Printed Page ?
Example code, Chapter 1

Originally submitted in Head First Rails book forum:
http://forums.oreilly.com/content/Head-First-Rails/3803/Rails-Version-Matters/#entry10675

Changes in html.erb files and database weren't visible in Rails version 2.3.2. I finally found that if I installed rails gem version 2.1.2, which is what the downloaded code uses, my code works.

Maybe you should check this out and either figure out how to make the code work with rails v 2.3.2, or warn people in your Read Me preface not to go with 2.3.2.

Note from the Author or Editor:
I have emailed Brett Mclaughlin to see how best to handle it

Anonymous 
Safari Books Online 4-5
answer to list items 2 and 3

Answers to questions 2 & 3 are reversed

Note from the Author or Editor:
Pool puzzle answers 2 and 3 on page 6 need to be switched.

Ron Bingham 
Safari Books Online 20
3rd paragraph

"separated according to it's function"

should be "its"

Kathy Jacobson 
Safari Books Online 30
Inside the man's talking bubble

'suposed' should be changed to 'supposed'

Note from the Author or Editor:
"bookings are suposed" in the boss' speech bubble should be replaced with "bookings are supposed"

Brett Goulder 
Printed Page 36
Block with code added to show.html.erb

Bold code shows email_address; should be phone.

Note from the Author or Editor:
The code highlights the wrong piece of code and does not display the code that was added. Instead of showing this:
<p>
<b>Price paid:</b>
<%=h @ticket.price_paid %>
</p>

<p>
<b>Email address:</b>
<%=h @ticket.email_address %>
</p>

<p>


It ought to show this:

<p>
<b>Email address:</b>
<%=h @ticket.email_address %>
</p>

<p>
<b>Phone:</b>
<%=h @ticket.phone %>
</p>


The paragraph with the phone information ought to be emboldened.

sean kearney 
Printed Page 36
1st paragraph

An 'is' is missing after 'it': "once the code has been generated it the developer's ..."

Gabriele Bartolini 
Printed Page 51
DB Table 'ads' on right side of page

There is an arrow with text "This is the generated primary key." which points to somewhere where it could be misunderstood. It should refer to only the 'id'-row. It could also be read and understood that it refers to all three rows ('id', 'created_at' and 'updated_at') which are surrounded.
Greetings from Freiburg in lovely Germany

Note from the Author or Editor:
The penciled loop associated with the annotation should only include the id field.

Mike Just 
Printed Page 54
2nd paragraph: text

Text: ..."If someone asks for for ad#3..."
Double word "for for", change to "for".

Greetings from Freiburg in lovely Germany

Mike Just 
Printed Page 60
10th question

The 10th question is in singular form, although it should be in plural.

Question in the book is: Why are the templates in a folder called "views/ad" but the controllers are not in "controllers/ad?

The correct version is: Why are the templates in a folder called "views/ads" but the controllers are not in "controllers/ads?

Note from the Author or Editor:
"views/ad" should be changed to "views/ads" and "controllers/ad" should be changed to "controllers/ads"

Anonymous 
Safari Books Online 61
3rd line of code

missing single quote at end of line:
'show
should be 'show'

Kathy Jacobson 
Printed Page 61
Diagram on the right showing contents of the view directory

The page templates shown in the diagram all end with *.html.rb extension. Shouldn't they be *.html.erb since they will be processed by ERb?

Note from the Author or Editor:
The .html.rb extensions on that page should be html.erb

Winston Tsai 
Printed Page 70
'Congratulations!' paragraph

"What's more, you taken a peek..." should be
"What's more, you've taken a peek..."

Note from the Author or Editor:
"you taken a peek" should be "you've taken a peek"

K. Oster 
Printed Page 72
note for 'params[:id]' in 'Pool Puzzle Solution'

"...user is asking for /ads/3, ..." should be
"...user is asking for /seller/3, ..."

Note from the Author or Editor:
In the intro paragraph on pages 71/72, "/seller/:id" should be "/sellers/:id"

In the annotation on page 72 "/ads/3" should be "/sellers/3"

K.Oster 
Printed Page 73
note for 'All Ads' webpage screen shot

'An index pag.' should be 'An index page'

Note from the Author or Editor:
Annotation on the "All Ads" page should be "An index page."

K.Oster 
Printed Page 75
Routing example

One forward slash missing from the routing example if we want to stay consistent. Second line should read /ads/ instead of ads/

The code in the book is as follows:
map.connect '/ads/:id', :controller => 'ads', :action => 'show'
map.connect 'ads/', :controller => 'ads', :action => 'index'

It should be:
map.connect '/ads/:id', :controller => 'ads', :action => 'show'
map.connect '/ads/', :controller => 'ads', :action => 'index'

Note from the Author or Editor:
The line of code beginning:

map.connect "ads/"...

should be

map.connect "/ads/"...

Anonymous 
Safari Books Online 82
answer #2

It doesn't keep it's own

should be
It doesn't keep its own

Kathy Jacobson 
Safari Books Online 85
first line

'form_for' helper

We are actually using the 'remote_form_for' in both _edit.html.erb and _new.html.erb

Kathy Jacobson 
Printed Page 89
first block of code: line 2

(Beyond Scaffolding)
Loops can be added to page
templates using scriplets

The block of code a the top pointed to by the long arrow:

for ad in @ads
print '<li><a href="'
print ad.id
print '">'
print ad.name
print '</a></li>'
end

should read: ( added to line 2: /ads/ )

for ad in @ads
print '<li><a href="/ads/'
print ad.id
print '">'
print ad.name
print '</a></li>'
end

hing hoo bird 
Printed Page 93
Lower 3rd

Download this!
Instructions are to download style sheet, but no style sheet is given at web address. I checked the public directory for chapter2 and it is not in the zipped file either.

Note from the Author or Editor:
A copy of the file public/stylesheets/default.css needs to be taken out of http://www.headfirstlabs.com/books/hfrails/code/chap2_hfrails_code_20081127.zip and given a separate link on http://www.headfirstlabs.com/books/hfrails/ just as development.sqlite3 currently is.

It will obviously also need to remain in the zip file.

Anonymous 
Printed Page 95
screenshot

I downloades and uses the layouts/ads.html.erb as explained in chapter 2. However when I later created the form on page 112 it breaks the layout, so that the content runs down into the footer. This despite of the thet fact that <%= yield %> is in <div id="content">?

Why is this?

Thanks

Note from the Author or Editor:
It's a stylesheet issue. Doesn't handle browser resize very well.

Anonymous 
Printed Page 111,112
1st paragraph

The <% form for %> tag is missing an underscore.
It should be <% form_for %>

Winston Tsai 
Printed Page 114
Note for '@ad = nil'

'...no other attributes avaialble, ..." should be
'...no other attributes available, ..."

Note from the Author or Editor:
"Available" is mis-spelled in the top annotation.

K.Oster 
Printed Page 114
diagram


Okay so you state - hey before you reference @ad you have to create in the controller. Excellent. Did it. Have the view for new.html.erb. But no form. Just the words "New ad".

tried moving you app folder over mine. Same result. No form.
2 hours later. Looked at rails documentation
http://api.rubyonrails.org/
at Module
ActionView::Helpers::FormHelper

Whoa - none of the example say the way you are calling is valid.
Changed your code:
<% form_for(@ad,:url=>{:action=>'create'}) do |f| %>

to

<% form_for :ad,:url=>{:action=>'create'} do |f| %>

Bam!! It works - sooooooo.

or you could also change it to:

<% form_for(:ad, @ad,:url=>{:action=>'create'}) do |f| %>

Otherwise thank you for a wonderful book. Wow what a way to learn. you guys rock!!!

Note from the Author or Editor:
Replace "@ad" in the second line of the HTML on page 114 with ":ad"

farida memon 
Printed Page 115
(3) in the diagram

"new html.erb" should be "new.html.erb"

Akira Matsuda 
Printed Page 140
Test Drive screenshots

The second and fourth screen shots should be switched.

The 'All Ads' screenshot should forward link to the screenshot with Description of 'Suit person with left foot'

The 'Editing Leather boot' screenshot should forward link to the screenshot with Description of 'High quality kid-leather...'

Note from the Author or Editor:
The screenshots with "/ads/40" at the ends of the URLs need to be switched.

K.Oster 
Printed Page 143
line 1 of code box

The class should read"AdsController" and not "AdController"

Raymond Jenkins 
Safari Books Online 160
next to last paragraph

"requires needs a model object to work."

choose one of "requires needs"

Note from the Author or Editor:
Change to "needs"

Kathy Jacobson 
Printed Page 161
bottom

One of the fridge magnets has a typo. The magnet "search_string" should be :search_string

Note from the Author or Editor:
The magnet containing:

"search_string"

should contain

:search_string

Anonymous 
Printed Page 161
magnets

The magnets offer the choice of "search_string", but in the solution on the next page, the answer is :search_string.

Anonymous 
Printed Page 164
Under "Ready Bake Code

The URL to download the "ready bake code" ends in books/rails. The correct URL ends in books/hfrails.

Anonymous 
Printed Page 166
3rd paragraph

The paragraph starts with: WIth a model form ...

The second letter is capital, should be corrected to: With a model form ...

Note from the Author or Editor:
"WIth" should be "With"

Anonymous 
Printed Page 166
page title

params is not an Array but a Hash.

Page title "use the params array" should be
"use the params hash"

Note from the Author or Editor:
Replace "use the params array" with "use the params" (don't use either the word "hash" or "array") because params is neither.

Akira Matsuda 
Printed Page 169
Last paragraph

'...the string the user is searching form.' should be
'...the string the user is searching for.'

Note from the Author or Editor:
"is searching form" should read "is searching for"

K.Oster 
Printed Page 170
Answer to first question of 'there are no Dumb Questions'

'...no object to with a single...' should be
'...no object with a single...'

Note from the Author or Editor:
'...no object to with a single...' should be
'...no object with a single...'

K.Oster 
Safari Books Online 173
2nd paragraph

"finder for each of it's attributes"

it should be "its"

kajaco2 
Printed Page 181
Second note for parameterized code statement

'...and avoid a type security attack...' should be
'...and avoid a type of security attack...'

Note from the Author or Editor:
"type security" should be "type of security" in the final annotation.

K.Oster 
Printed Page 190
Screenshot under 'Editing bad data'

If the user is on the edit form page, shouldn't the button show 'Update' instead of 'Create'?

Note from the Author or Editor:
Needs an updated screenshot for the edit screen. You will need to contact me.

K.Oster 
Printed Page 196
First paragraph

'Some people are have been leaving...' should be
'Some people have been leaving...'

Note from the Author or Editor:
"Some people are have" should be "Some people have"

K.Oster 
Safari Books Online 196
2nd paragraph

"trainer's name need to completed"

should be "need to be completed"

Note from the Author or Editor:
Should be:

"Trainer's name needs to be completed"

kajaco2 
Printed Page 203
Last paragraph

'...on new adds were completed,...' should be
'...on new ads were completed,...'

Note from the Author or Editor:
"adds were" should be "ads were"

K.Oster 
Printed Page 220
Section heading

'Coconut Airways need a booking system' should be
'Coconut Airways needs a booking system'

Note from the Author or Editor:
'Coconut Airways need a booking system' should be
'Coconut Airways needs a booking system'

K.Oster 
Printed Page 231
Sentence under show.html.erb flight page

'The render call tell Embedded Ruby...' should be
'The render call tells Embedded Ruby...'

Note from the Author or Editor:
'The render call tell Embedded Ruby...' should be
'The render call tells Embedded Ruby...'

K.Oster 
Printed Page 242
3rd paragraph

The word 'new' ("...to provide the new _seat_list.html.erb partial...") has the wrong font; it should have the same font as the preceding word, 'the'.

Note from the Author or Editor:
"provide the new" should all be in the Body style.

K.Oster 
Safari Books Online 242
Code box, last note

"Remove the list to"

should be "Remove the link to"

kajaco2 
Printed Page 242
1st paragraph

New partial is given name _seat_list.html; thereafter it is referred to as _seat_list.html.erb

Anonymous 
Printed Page 246
last sentence

Seat.find_all_for_flight_id(...)

should be:

Seat.find_all_by_flight_id(...)

Ivo Balbaert 
Printed Page 247
directory tree in the right side

app
views
flight.rb
should be
app
models
flight.rb

Akira Matsuda 
Printed Page 254
last figure right

The figure should read: app models seat.rb

instead of: app views seat.rb

Ivo Balbaert 
Printed Page 265
first paragraph, line 4

The file ending .erb should be formatted the same way as the rest of the file name: app/views/flights/show.html..

Note from the Author or Editor:
Change the font of the "erb" at the start of the line so that it is in code style.

jhs06r 
Safari Books Online 269
2nd paragraph

Last line ends in "return it to the browser."

This should be, "returns it to the browser."
(The controller looks...generates...and returns...)

kajaco2 
Safari Books Online 269
diag showing "Listing seats" and diag showing HTML code

The heading for "Flight" should be deleted, i.e., instead of "Flight Name Baggage", it should be "Name Baggage". This can be achieved by deleting the line in the HTML code:
<th>Flight</th>
from the file _seat_list.html.erb (under /app/views/flights).
Actually this (deletion) should have been done on pg.242 in Ch. 6.

Winston 
Safari Books Online 275
6th answer (top of right column)

"The presence of the value in a request show that a request..."

'show' should be 'shows':
"The presence of the value in a request shows that a request..."

kajaco2 
Printed Page 275
Answer to the questions[-2]

The answer says the javascript_include_tag helper "adds a random number", but that's not true.
The helper actually adds the target file's mtime.to_i value.

Note from the Author or Editor:
Change "random number" to "long number"

Akira Matsuda 
Printed Page 275
Answer to the questions.last

The answer describes as though a new copy of the asset file will everytime be downloaded as the users request the page, but it's untrue.
A new copy of the file will be downloaded only when the file was updated or the browser missed the cache.

Note from the Author or Editor:
Change the last answer to:

"It means that if anything changes in your JavaScript library, the user will always get the latest version."

Akira Matsuda 
Printed Page 287
2nd paragraph

"But how do we make this the..." should be
"But how do we make this..." or
"But how do we make the..."

Note from the Author or Editor:
s/be "But how do we make the form work..."

Akira Matsuda 
Printed Page 298
1st paragraph

"you might expect that you will need to how to write JavaScript code" should be
"you might expect that you will need to know how to write JavaScript code"

Akira Matsuda 
Printed Page 299-300
First paragraph (both pages) and code magnets on page 299

"...the HTML in the 'notices' <div/>..." should be
"...the HTML in the 'notice' <div/>..."

The 'notices' code magnet should be a 'notice' code magnet on page 299.

Note from the Author or Editor:
On page 299 change the instructions on the Code magnets from:

...HTML in the 'notices'...

to

...HTML in the 'notice'...

Change the 'notices' magnet to 'notice'

K.Oster 
Safari Books Online 302
Near the top

It would be helpful to say which file this is from. I've assumed _new_seat.html.erb, since we are creating a new seat.

Note from the Author or Editor:
Add an annotation to the code and label it:

_new_seat.html.erb

kajaco2 
Printed Page 304
the last paragraph

"the page object will generate code to updates the notice" should be
"the page object will generate code to update the notice"

Akira Matsuda 
Printed Page 304
Heading

The heading says "The completed code CAN WILL now do several things"
It should be:
"The completed code can now do several things"

jhs06r 
Printed Page 318
Last paragraph

'...we used Ajax to download new version...' should be
'...we used Ajax to download a new version...'

K.Oster 
Printed Page 332

in the code: :root => "name" should read: :root => "data"

Ivo Balbaert 
Printed Page 335
4th A[nswer], 4th line

"and you will found several places" should read
"and you will find several places"

Steve Hoogheem 
Printed Page 349
2nd to last sentence

'...and the XML bulder template...' should be
'...and the XML builder template...'

K.Oster 
Safari Books Online 351-2
1st paragraph (instructions)

"you won't need to use all the snippets"

Not true: all 10 items are used.

Note from the Author or Editor:
Add another "end" snippet on both page 351 and 352.

Kathy Jacobson 
Safari Books Online 362
3rd paragraph

"...our action will need to generated from a partial..."

should be "...need to be generated..."

Kathy Jacobson 
Printed Page 369
First paragraph

"Once you've clicked on the save button, you're to the cut down..."

should read:

"Once you've clicked on the save button, you're redirected to the cut down..."

David "Sweet" Robinson 
Printed Page 371
bottom

Why is params using strings here, params['latitude'] and param['longitude'], instead of symbols, params[:latitude] and params [:longitude]?

There are many examples of params[:id], including back on pages 362 & 364. And there's params[:seat] on p. 289.

Note from the Author or Editor:
Contacted the learner direct.

Steve Hoogheem 
Printed Page 373
1st para

On this page, the scenario described is that the form remains displayed on the same screen after "create" is submitted. However, this is not what happens - the user is actually sent to another screen via `redirect_to(@incident)`.


This is borne out on pg 337, depicting existing code:

format.html { redirect_to(@incident) }


Full method:

def create
@incident = Incident.new(params[:incident])

respond_to do |format|
if @incident.save
flash[:notice] = 'Incident was successfully created.'
format.html { redirect_to(@incident) }
format.xml { render :xml => @incident, :status => :created, :location => @incident }
else
format.html { render :action => "new" }
format.xml { render :xml => @incident.errors, :status => :unprocessable_entity }
end
end
end


Also worth noting, since we're no longer redisplaying the "new.html.erb" form, there is no <%= f.errors %> tag to display the flash message to, so the "flash" code has no visible effect.

HTH,
Cosmo

Note from the Author or Editor:
2ns screenshot is wrong. It should show a read-only view of the data, rather than the form.

Cosmo Lee 
Safari Books Online 377
top left corner

The file tree containing the _new.html.erb file is missing the incidents directory. It should have this structure:
app/views/incidents/_new.html.erb

Kathy Jacobson 
Safari Books Online 380
Answer #2

"...calls all of it's own..."

should be "...its..."

Kathy Jacobson 
Safari Books Online 385
Answer #1

"That return true..."

should be "That returns true..."

Kathy Jacobson 
Printed Page 389
Bottom of page

When updating this code using a route helper:
<p><%= link_to "Edit", "/incidents/#{incident.id}/edit" %></p>

Shouldn't the updated code use edit_incident_path instead of edit_incident_url?

Note from the Author or Editor:
edit_incident_url should be replaced with edit_incident_path

K.Oster 
Printed Page 391
2 code examples near bottom

I assume the correction on p. 389 replacing "edit_incident_url" with "edit_incident_path" carries forward to this page too, in both code examples near the bottom of the page.

Steve Hoogheem 
Safari Books Online 396
last paragraph

"Well that works pretty like the new form did."

pretty much?

Kathy Jacobson 
Printed Page 397
Answer to first question

'...harder to reader and...' should be
'...harder to read and...'

K.Oster 
Printed Page 397
5th A[nswer] & 7th A[nswer]

Are PUT and POST swapped on this page?

Looking the "rake routes" output on p. 388 (and repeated on pp. 393 & 394):
1. an http POST (in both rows) causes a create action.
2. an http PUT (in both rows) causes an update action.

5th A[nswer]:
"PUT is used for requests that will create new records ..."
should be
"PUT is used for requests that will update records ..." ?

7th A[nswer]:
"If the object has already been saved, then form_for generates a form that will use the POST action. If the object is new, then it will generate a form that uses PUT."
should be
"If the object has already been saved, then form_for generates a form that will use the PUT action. If the object is new, then it will generate a form that uses POST." ?

Note from the Author or Editor:
7th answer on p. 397 - swap "POST" and "PUT"

Steve Hoogheem 
Printed Page 398
bottom

"Visti us here for details..." should be "Visit..." (?)

Akira Matsuda 
Printed Page 401
1st paragraph

How do you make the most out **the** Rails and the Ruby language?

Note from the Author or Editor:
Change text to be:

How do you make the most out of Rails and the Ruby language?

Anonymous 
Printed Page 405
the last one in the left column

"Pretty-print the contents of an array"
should be "Pretty-print the contents of a hash"

Akira Matsuda 
Printed Page 405
right side

"alias my_method" will cause syntax error.
It should be
"alias another_name my_method"
or sth.

Akira Matsuda 
Printed Page 408
2nd paragraph

"That why" should be "That's why"

Akira Matsuda 
Printed Page 409
middle

development:
adapter: oracle

should read:
production:
adapter: oracle

Ivo Balbaert 
Printed Page 409
first example

development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000

should be

production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000

Akira Matsuda 
Safari Books Online 411
Caption for illustration at bottom of page

"These are the used in the RESTful routes in a scaffold application."

should be "These are the urls..."

Kathy Jacobson 
Printed Page 411
last section

"The third principle... there should __ a well defined..."

Missing "be" a well defined...

Anonymous 
Printed Page 412
2nd para, 3rd para

2nd para:
Rails make*S* it really..

3rd para:
Play with paths [period]

6th para:
...latest version of the rails scripts... cap. Rails

Anonymous 
Printed Page 412
6th paragraph

rake rails:freeze:edge
installs Edge Rails into vendor/rails directory. Not vendor/plugins

Akira Matsuda 


"I suggested Head First Rails to a friend before I even finished it. He was asking me questions that I didn't have time to answer, and I knew the book could explain better than I."
--Anita Kuno, Slashdot.org