By Developers, For Developers

Historical errata for Rails Recipes

PDF PgPaper PgTypeDescriptionFixed onComments
71ERROR

The surrounding text reads like the User model should not yet have the has_many :meetings association.

2011-11-08
67ERROR

On page 67 there is the User class with 3 has_many relationships. On page 68, there is the User class, stating there has been an added line, but there are still only 3 relationships. The first User class on page 67 is not supposed to have “has_many :meetings, :through => :groups”

2011-11-08
69TYPO

“Unfortunately, many of our Rails applications’ were either created before they were moved to Rails or were created by someone not ready to use the migration functionality.”

Seems to be missing a word (possibly database) after “applications’ ”

2011-11-08
75ERROR

Discussion of create! should state that exception is raised for INvalid record, not valid record (bottom 3rd of page)

2011-11-08
54SUGGEST

Solution - first paragraph - “we can use map flat data structure to objects”. I think there’s a missing “to”. It should be “”we can use to map flat data structure to objects".

2011-11-07
68ERROR

The solution starting on page 67 has a User class that per the text ‘the models would traditionally look like these:’ leading the reader to expect a ‘before the solution’ code block. The User class definition immediately following is identical to the block on page 68 which is listed right below the text “First, we need to reconfigure
the User model like so” suggesting that a change had been made to the User model, when none had been.

2011-11-08
15SUGGEST

Rails 3.1 migrations no longer need to use “self” in the up and down methods and hence can be omitted.

2011-12-11
129ERROR

csrf_meta_tag has been renamed to csrf_meta_tags <— note the plurization

2011-11-08
12TYPO

First paragraph, second sentence:

“Since we need to pass text query text into the scope, we define …”

I think that should probably read “Since we need to pass query text into the scope, we define …”

2011-11-07
78ERROR

What we have here is typical ActiveRecord code. The one unusual aspect is that we’re using the create!() method instead of the usual create() method. The <!> version of create() (and of save()) raises an exception when the record is valid.

AR raises an exception with create/save! when the record is invalid.

2011-11-08
26ERROR

the create of a grade references a :class which is not defined in the migrations

create_table :grades do |t|
t.belongs_to :student
t.integer :score
t.timestamps
end

me.grades.create(:score => 1, :class => “Algebra”)

2011-11-07
49TYPO

I think you are missing the word “to” in the following snippet

which, it so happens, we can use [to] map flat data structure to objects.

2011-11-07
111TYPO

In the last paragraph FeedController is missing the s.

2011-11-08
132TYPO

The code file rr2/ajax_with_jquery/app/views/people/index.html.erb is referenced twice on this page. Looks like the second reference to that file should point to rr2/ajax_with_jquery/app/views/people/_person.erb (which I think should actually be _person.html.erb)

2011-11-08
26ERROR

#1: belongs_to :student is not declared
#2: the class column is not defined in the migration
#3: ‘class’ seems to be a reserved word. Use ‘course’ instead

2011-11-07
49TYPO

Two ‘the’ in “…for the course in the the student’s record”

2011-11-07
150TYPO

In the Album model generation command line “$ rails g model Album title:string artist:string invoke”, the command ends with “invoke” — when that command should end with “artist:string” and the next line should be “invoke active_record”

2011-11-08
189TYPO

Text:
“Sometimes we need to dynamic generate attribute values based on other attributes in our sample data”

Should probably be “dynamically generate”

2011-11-08
129TYPO

First Paragraph:
…one which shows only administrators and one which shows everyone without relaoding the entire page?

relaoding => reloading

2011-12-11
93TYPO

Duplicate “needs”: not every REST controller needs needs them.

2011-12-11
4ERROR

In the schema Magazines have a title attribute. Whereas in the following example, a Magazine is instantiated with a name attribute.

2011-12-11
93TYPO

Typo: bcause

CRUD actions, and bcause the resources() router
method automates the mapping of those

2011-12-11
93TYPO

“Worse that these concerns, however, is that forgotten code”
should read “Worse than …”

2011-12-11
109TYPO

“Suffice it to say that RSS and Atom both involve”
should be “Suffice to say” or “Suffice is to say”?

2011-12-11
128TYPO

“The key to understanding the Solution”
Solution should be small “s”

2011-12-11
58ERROR

In the Person model, there is a reference to :class_name using the :through option. Shouldn’t this be :source => “Person” instead (in reference to the footnote on page 7). From the has_many :through entry of the API “Options for :class_name, :primary_key and :foreign_key are ignored, as the association uses the source reflection.”

2011-12-11
33TYPO

Wrong form of the word “its” in the following sentence: “As a demonstration of it’s power…”

2011-12-11
267TYPO

The line in the second-to-last paragraph starting ‘If you’re
still running Ruby 1.9, use ”ruby-debug”…’ should read ‘If you’re still running Ruby 1.8, use “ruby-debug”…’.

2011-12-11
193ERROR

When testing the /users/new path, I get an error message in my browser “bcrypt-ruby is not part of the bundle. Add it to Gemfile.” Adding “gem ‘bcrypt-ruby’” to the Gemfile and running bundle install solves this issue.

Ruby 1.9.3-p0, rails 3.1.1.

2011-12-11
168TYPO

On the third paragraph there’s a type in word give - it should be given.

2012-02-12
257TYPO

At the top of the page, the first full sentence reads:
“Any easy way to run this script would be to use rails runner like this:”

“Any” should be “An”

2012-02-12
22TYPO

In Recipe 4, there should presumably be a default_scope, not just a scope in rr2/default_scopes/app/models/product.rb

2012-02-12
42TYPO

In Recipe 8, the results of Donation.group(:created_at).sum(:amount)
all have the exact same datestamp, even though the explanatory text says that it should be grouping by day. Either the results or the explanation is wrong (and it’s not clear to me why the group(:created_at) should necessarily group by day rather than e.g. hour.)

2012-02-12
30ERROR

On top of this PDF-page there is an error box:

“30 • This book contains code that’s too wide. Look in the build log for details and fix.”

2012-02-12
129TYPO

At end of Problem statement:
“without relaoding the entire page?”
Should say reloading…

2012-02-12
127TYPO

At beginning of Problem statement:
“Layouts are a great way to keep the view code of your application free or duplication while maintaining a consistent structure its pages.”
‘or’ should be ‘of’ and maybe a ‘to’ is missing before ‘its pages’…

2012-02-12
338ERROR

In Recipes # 51 there is a minor error that routes to the incorrect path.

It currently reads:

<%= form_tag session_path do %>
…
…
…
<end>

But should read:

<%= form_tag new_session_path do %>

2012-02-12
6TYPO

“the association is implicit through the :through parameter to the has_many() declarations.”
I think that should be
“…through the :through parameter OF the has_many() declarations.”
The has_many() declarations do HAVE a :through parameter.

2012-02-12
11TYPO

“neither of these scopes accept parameters. To
demonstrate how to create a scope that accepts does,”
Should be
“…how to create a scope that accepts those,”

2012-02-12
57TYPO

“uesful” (“Problem” paragraph) should be “useful”

2012-02-12
22TYPO

scope :available, where(:available => true)

should be

default_scope :available, where(:available => true)

1292SUGGEST

Why isn’t the book written using MVC approach. Everything Rails, from tutorials to screencasts use MVC so that readers can see how every piece fits together. I wish I could get my money back. The book is almost useless when all you had is the Models.

247TYPO

Recipe: “Create Your Own Ruby Gem”

After you show the .gemspec file you say “we’ve told RubyGems that our library requires a version of HTTParty in the 1.6 family to be compatible” but in the gemspec file you call s.add_dependency “httparty”, “~> 0.6”.

Currently HTTParty is at version 0.8.1 so I guess you meant “in the 0.6 family”.

54TYPO

Recipe: 10 - “Connect to Legacy Databases”

Code is in a CDATA section.
When you show how to find and destroy a comment (from the Rails console) the code is in a CDATA section (<![[CDATA​​ … ​​]]>​​), I guess is some kind of “book markup” that should not be seen.

PS: I wrote PDF page 54 because it’s on the 54th page of the PDF but I don’t know if you want the page number shown in the top-right corner of the page for the erratum.

64TYPO

Recipe: 14 - “Create Self-referential Many-to-Many Relationships”

You refer to a Friend model in the phrase “…given the existence of both a Person model and a >>>Friend<<< model.” but maybe you meant the Friendship model since there is no Friend model in this recipe.

10TYPO

The link to the Pragmatic Programmers Rails Recipes forum is the old forum. The forum id is 189, not 8. (I couldn’t post the corrected url - the form prevents hyperlinks being posted.)

140TYPO

Recipe 38 - the last code example on the page contains the line ‘songs.sum(&:duration_in_seconds)’, which should be ‘songs.sum(:duration_in_seconds)’

267TYPO

“You’ll notice the call to isolate_engine().” should be “… isolate_namespace().”.

236SUGGEST

The example orders_controller.rb should have the lines

format.csv { instead of format.csv do
…
} instead of end

76SUGGEST

The example for this recipe doesn’t do anything with the registration form once an event is created which is the whole purpose of the recipe.

The reason I’m interested in this recipe is that I have problem I was looking for help with, and I was hoping this example would help me add multiple detail records on a single page (multiple registrations for an event on 1 page). My hope was I could see the routing through web pages by looking at a form that adds multiple registrations on a single page, then use that example to help me figure out the routing and controller structures for my app. Its not so much the form I’m interested in as much as a working example that is similar to my situation so I can glean some clue for how I might solve my problem. I understand if my problem is outside the scope of this example but at the very least it should do something with the registration page. And if this isn’t the place for registering example issues then I’m sorry.

237TYPO

In the paragraph under the orders_controller.rb code, the final sentence says: “We use the generate() method on the CSV class to create a CVS generator…”. “CVS” should be “CSV”.

Categories: