We try to keep our books accurate, but sometimes mistakes creep
in. This page lists the errors submitted by our astute readers.
If you've found a new error, please
submit it.
The latest version of the book is P3.0,
released almost 6 years ago.
If you've bought a PDF of the book and would like to upgrade
it to this version (for free), visit your
home page.
| PDF |
Paper |
Description |
Found in |
Fixed in |
|
1 |
#29653: It would be easier to find the samples in the download if they were ordered by Chapter Number. (JMHO)--TW Scannell
|
P3.0
13-Sep-07
|
|
| 13 |
|
#29023: in_place_select_editor is missing some options that are in:
See the rdoc for JavaScriptMacrosHelper.html
This seems to work:
def in_place_select_editor(field_id, options = {})
function = "new Ajax.InPlaceSelectEditor("
function << "'#{field_id}', "
function << "'#{url_for(options[:url])}'"
js_options = {}
js_options['cancelText'] = %('#{options[:cancel_text]}') if options[:cancel_text]
js_options['okText'] = %('#{options[:save_text]}') if options[:save_text]
js_options['loadingText'] = %('#{options[:loading_text]}') if options[:loading_text]
js_options['savingText'] = %('#{options[:saving_text]}') if options[:saving_text]
js_options['rows'] = options[:rows] if options[:rows]
js_options['cols'] = options[:cols] if options[:cols]
js_options['size'] = options[:size] if options[:size]
js_options['externalControl'] = "'#{options[:external_control]}'" if options[:external_control]
js_options['loadTextURL'] = "'#{url_for(options[:load_text_url])}'" if options[:load_text_url]
js_options['ajaxOptions'] = options[:options] if options[:options]
js_options['evalScripts'] = options[:script] if options[:script]
js_options['callback'] = "function(form) { return #{options[:with]} }" if options[:with]
js_options['clickToEditText'] = %('#{options[:click_to_edit_text]}') if options[:click_to_edit_text]
js_options['selectOptionsHTML'] = %('#{escape_javascript(options[:select_options].gsub(/\n/, ""))}') if options[:select_options]
function << (', ' + options_for_javascript(js_options)) unless js_options.empty?
function << ')'
javascript_tag(function)
end--Ian Connor #29023: in_place_select_editor is missing some options that are in:
See the rdoc for JavaScriptMacrosHelper.html
This seems to work:
def in ...more...
|
P3.0
14-May-07
|
|
| 13 |
|
#39018: Scriptaculous in_place_editor does not work with Rails 2.1 as described in the book.--Tim DeBaillie
|
P3.0
27-Apr-09
|
|
| 32 |
|
#25916: "we put relative path to our JavaScript
action" -- it's an absolute path, no?--Mark Meves
|
P3.0
14-Sep-06
|
|
| 45 |
|
#43308: Not sure whether the code here is correct in Rails 2.3.x
What I have working so far is:
module ApplicationHelper
class TabularFormBuilder < ActionView::Helpers::FormBuilder
(field_helpers - %w(check_box radio_button hidden_field)).each do |selector|
define_method "#{selector}" do |field, *options|
@template.content_tag("tr",
@template.content_tag("td", field.to_s.humanize + ":") +
@template.content_tag("td", super))
end
end
end
end
--Patrick Mulder #43308: Not sure whether the code here is correct in Rails 2.3.x
What I have working so far is:
module ApplicationHelper
class TabularFormBu ...more...
|
P3.0
18-May-10
|
|
| 46 |
|
#29400: I tried the code, and the class CodeStatistics was not known. So I had to include require 'code_statistics' to get it to work.--Markus Liebelt
|
P3.0
13-Aug-07
|
|
| 53 |
|
#25410: I'm not sure of the version of the text used in what I saw, because it is the pdf extract for "Rails Without a Database" (I do not currently have an actual copy of the book, or the full pdf).
Anyway, on page 53 the example DatabaselessApplication/lib/tasks/clear_database_prerequisites.rake does not really work. If you use the example code given, rake test_units will not run any of your unit tests. The task which actually needs to have its prerequisites cleared is test:units, not test_units. Clearing test_units prereqs causes the unit tests to not be run at all. Here is code I'm using in my database-less rails app to make all the rake test_* tasks work:
[:'test:units', :'test:functionals', :'test:recent', :'test:uncommitted', :'test:integration'].each do |name|
Rake::Task[name].prerequisites.clear
end
--Nick #25410: I'm not sure of the version of the text used in what I saw, because it is the pdf extract for "Rails Without a Database" (I do not currently h ...more...
|
P3.0
07-Jul-06
|
|
| 55 |
Ztdaz |
#35967: good guest page.
thank you.--gUuSOTgJueBOqIGst
|
P1.0
18-Nov-08
|
|
| 57 |
|
#25943: In the final sentence of the first paragraph:
... all of its child classes (your application-specific) models.
should read:
... all of its child classes (your application-specific models).
right? Thanks.
--Mark Meves #25943: In the final sentence of the first paragraph:
... all of its child classes (your application-specific) models.
should read:
... al ...more...
|
P3.0
19-Sep-06
|
|
| 61 |
|
#25944: In the second sentence of the second paragraph, "You'd" should not be capitalized. --Mark Meves
|
P3.0
19-Sep-06
|
|
| 71 |
|
#29175: Recipe 19, "Tagging Your Content", uses a plugin that is no longer available. Attempting to follow the book fails at the first step (script/plugin install acts_as_taggable). The plugin is now considered legacy, as per DHH comment on dev.rubyonrails.org. The book needs to instruct on how to retrieve a legacy plugin, or (preferred) be updated with one of the community-supported tagging systems (agilewebdevelopment.com/plugins/search?search=acts_as_taggable) #29175: Recipe 19, "Tagging Your Content", uses a plugin that is no longer available. Attempting to follow the book fails at the first step (script/pl ...more...
|
P3.0
31-May-07
|
|
|
75 |
#28316: 3rd paragraph: "Now we can find and destroy records by their primary keys:" An example follows which is wrapped in <![[CDATA ]]> tags by mistake. (These tags probably originate from some error in the XML source of the book.)--Sergei Yakovlev #28316: 3rd paragraph: "Now we can find and destroy records by their primary keys:" An example follows which is wrapped in <![[CDATA ]]> tags by mista ...more...
|
P3.0
04-Apr-07
|
|
| 78 |
|
#31094: script/plugin discover
script/plugin install acts_as_versioned
--- This doesn't work
chapter.version
--- This doesn't work either
As I got the book specifically for acts_as_versioned - I have to say I was quite dissapointed--Ran Moshe #31094: script/plugin discover
script/plugin install acts_as_versioned
--- This doesn't work
chapter.version
--- This doesn't work either
As ...more...
|
P3.0
01-Mar-08
|
|
| 80 |
|
#25356: In the 2nd example of versioning, the one that introduces chapter.revert_to(2), I don't understand the final version number. The example starts with 3 versions, then revert_to is supposed to add a new version according to the text, and then the title is modified and chapter.save is called. This should then bump up the versions again, so the final chapter.version should be 5. Ok, if that's not correct, then perhaps you could clarify the explanation a little :-).--Thorsten #25356: In the 2nd example of versioning, the one that introduces chapter.revert_to(2), I don't understand the final version number. The example start ...more...
|
P1.0
29-Jun-06
|
|
|
86 |
#28378: 4th paragraph: "--Sergei Yakovlev
|
P3.0
07-Apr-07
|
|
|
87 |
#32264: Instead of "detail.tags.collect.." should the following be "contact.tags.collect.." ?
<%= text_field_tag "tag_list",
detail.tags.collect{|t| t.name}.join(" "),
:size => 40 %>
The partial is called 'detail' while the model obj is 'Contact'
Typo or not, the book is great!--norbert.ryan3@gmail.com #32264: Instead of "detail.tags.collect.." should the following be "contact.tags.collect.." ?
<%= text_field_tag "tag_list",
detail.tags.co ...more...
|
P3.0
03-Jun-08
|
|
| 101 |
|
#28461: I found the GradeFinder example very useful... but it took me a while to figure out how to reuse GradeFinder for the base class. For example, while Student.find(1).grades.below_average works well, I can't readily use Grades.below_average
So, it seems to me, that in order to reuse the GradeFinder logic, I can just write "extend GradeFinder" in the class definition for Grade (just under the "class Grade < ActiveRecord::Base" statement). For a Ruby novice such as myself, it would be nice to have that in your book.--Zenon #28461: I found the GradeFinder example very useful... but it took me a while to figure out how to reuse GradeFinder for the base class. For example, ...more...
|
P3.0
11-Apr-07
|
|
|
112 |
#25966: Don't forget to save the changes to the database:
>> address.save--Manu Cammaert
|
P1.0
21-Sep-06
|
|
| 119 |
|
#25985: look at middle at page:
We can now simplify the signin action to look like this:
def signin
if request.post?
....
Now look at bottom of page:
def signin
session[:user] = User.authenticate(params[:username], params[:password]).id
....
IMHO, you forget add "if request.post?" in second time. So, user never saw login\password form and will be receive "Username or password invalid"
--Viacheslav Kaloshin #25985: look at middle at page:
We can now simplify the signin action to look like this:
def signin
if request.post?
....
Now look at bott ...more...
|
P3.0
26-Sep-06
|
|
| 130 |
|
#25845: Halfway down the page, you have the simplified signin action. At the bottom of the page, you pring the the entire controller, but the signin method there is missing the "if request.post?" test.--Eric Wagoner #25845: Halfway down the page, you have the simplified signin action. At the bottom of the page, you pring the the entire controller, but the signin m ...more...
|
P3.0
05-Sep-06
|
|
| 134 |
|
#25730: Your date route is spot-on, except for: "Defaulting to the current day" --Fred Alger
|
P3.0
16-Aug-06
|
|
|
136 |
#33166: Don't know is this is Rails 2.x specific, but self.password_salt, self.password_hash = salt, Digest::SHA256.hexdigest(pass+salt) should be self[:password_salt] = salt
self[:password_hash] = Digest::SHA2.hexdigest(pass+salt)
--Christopher Villalobos #33166: Don't know is this is Rails 2.x specific, but self.password_salt, self.password_hash = salt, Digest::SHA256.hexdigest(pass+salt) should be sel ...more...
|
P1.0
24-Jul-08
|
|
|
139 |
#26065: "if request.post?" is missing in the signin action of the full AdminController code listing (the last code piece on the page).--Hans-Eric Gr
|
P3.0
02-Oct-06
|
|
| 140 |
|
#26436: model_class = Object.const_get(table.classify) should be
model_class = Object.const_get(table.to_s.classify)
Otherwise you get an error NoMethodError: undefined method `classify' for :contacts:Symbol
if you pass in :contacts as shown in the example --Jim Morris #26436: model_class = Object.const_get(table.classify) should be
model_class = Object.const_get(table.to_s.classify)
Otherwise you get an error No ...more...
|
P3.0
30-Oct-06
|
|
|
142 |
#30703: At least using Rails 2.0.2, I get an "unknown table roles_users" message when I run this recipe. I had to add a new migration to rename roles_users to users_roles in order to get the code to execute without errors. So I think that the AddRolesAndRightsTables migration may need an update.--Ben Kimball #30703: At least using Rails 2.0.2, I get an "unknown table roles_users" message when I run this recipe. I had to add a new migration to rename roles_ ...more...
|
P3.0
05-Feb-08
|
|
|
146 |
#29374: Please give page numbers on ALL pages; not putting page numbers on blank pages and on the receipe front pages means that you can go several pages without a page number, making it hard to locate sections from the index. E.g., pages 146-149 have no page numbers.--Jon Seidel #29374: Please give page numbers on ALL pages; not putting page numbers on blank pages and on the receipe front pages means that you can go several pa ...more...
|
P3.0
30-Jul-07
|
|
|
149 |
#29372: In the description of the solution, you say that you will use an "after_filter", but then you actually implement a before_filter.--Jon Seidel
|
P3.0
30-Jul-07
|
|
|
149 |
#29373: The calculation in def session_expiry:
@time_left = (session[:expires_at] - Time.now).to_i
fails with the following error message:
NoMethodError (You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.-):
when the expiry time is exceeded. This method actually requires code such as:
if Time.now < session[:expires_at]
@time_left = (session[:expires_at] - Time.now).to_i
else
reset_session
render '/session/redirect'
end--Jon Seidel #29373: The calculation in def session_expiry:
@time_left = (session[:expires_at] - Time.now).to_i
fails with the following error message:
NoMe ...more...
|
P3.0
30-Jul-07
|
|
|
150 |
#31258: session_expiry() doesn't invoke the RJS template, this is the error it produces:
You called render with invalid options : /application/redirect
--Sigfrid Dusci
|
P3.0
17-Mar-08
|
|
|
151 |
#28338: Render CSV
Example code gives error: NameError in ExportController#orders
Need to add require "CSV"
|
B1.0
04-Apr-07
|
|
|
155 |
#26771: Mild grammatical : "We have multiple ways to achieve this affect, ..."
should that be "effect" ?
--John Simmonds
|
P1.0
20-Dec-06
|
|
| 173 |
|
#27556: The setup() method suggested doesn't appear to work with current Rails (1.2) -- namely the last line. An update to this recipe would be nice in future editions.--James H #27556: The setup() method suggested doesn't appear to work with current Rails (1.2) -- namely the last line. An update to this recipe would be nice ...more...
|
P3.0
12-Mar-07
|
|
| 197 |
|
#28969: It would seem to me that Recipe 49: "Dealing with Time Zones" ignores daylight saving time.
To have that included would be immensely helpful!--Sebastian Winkler
|
P3.0
09-May-07
|
|
| 198 |
|
#29337: The @headers instance variable is deprecated in Rails 1.2. Instead, simply remove the "@" symbol so that the headers setter method is called.
--Trevor Harmon
|
P3.0
18-Jul-07
|
|
| 199 |
|
#29336: If you get an error when calling CGI.rfc1123_date saying "undefined method `gmtime'", you are probably passing a Date object (instead of the required Time object) as a parameter. Simply use my_date_variable.to_time to convert it to a type that CGI can use.--Trevor Harmon #29336: If you get an error when calling CGI.rfc1123_date saying "undefined method `gmtime'", you are probably passing a Date object (instead of the r ...more...
|
P3.0
18-Jul-07
|
|
| 219 |
|
#29645: Image#save_fullsize should be using write, not puts to write out the binary data.--Ryan Davis
|
P1.0
10-Sep-07
|
|
| 228 |
|
#29646: I couldn't find this is the errata. In recipe 57 "Processing Uploaded Images", in Image#save_fullsize, you should be using write, not puts.--Ryan Davix
|
P3.0
10-Sep-07
|
|
| 234 |
|
#24933: Globalization example does not work.
Since I'm still waiting for the printed book and have no access to the beta, I'm referering to the excerpt (so this error might have been fixed already).
Before you can switch the locale and create a translation (here in ar-LB) you need to explicitely save and reload the record with the base locale.
For more info see here:
http://www.ruby-forum.com/topic/65900#79816 --Martin Bernd Schmeil #24933: Globalization example does not work.
Since I'm still waiting for the printed book and have no access to the beta, I'm referering to the exc ...more...
|
P1.0
20-May-06
|
|
|
243 |
#38079: In the example "SecretURLs/app/models/inbox.rb" the line
@attributes['access_key'] = MD5.hexdigest((object_id + rand(255)).to_s)
should read
@attributes['access_key'] = Digest::MD5.hexdigest((object_id + rand(255)).to_s)
the class also needs to require 'Digest' at some point.
--Scott Grimmett #38079: In the example "SecretURLs/app/models/inbox.rb" the line
@attributes['access_key'] = MD5.hexdigest((object_id + rand(255)).to_s)
should ...more...
|
P3.0
02-Mar-09
|
|
| 254 |
|
#25048: It seems that if you call the view for the HTML part "multipart_alternative", as is suggested in the manual, Rails will use this as the first part of the email, as well as the HTML part. This produces a three part email, instead of the desired two, and Mail at least presumes that the first part is the plain text alternative, which causes some problems. When I changed the name of the view being called to "multipart_alternative_rich" this solved the problem.--James Doy #25048: It seems that if you call the view for the HTML part "multipart_alternative", as is suggested in the manual, Rails will use this as the first ...more...
|
P1.0
25-May-06
|
|
| 272 |
|
#29302: It should be more clear than "The default generated model, Delivery, is sufficient for our needs on the Ruby side of the house." that the reader should be running
./script/generate model Delivery
early on on this page.--Edward Ocampo-Gooding #29302: It should be more clear than "The default generated model, Delivery, is sufficient for our needs on the Ruby side of the house." that the read ...more...
|
P3.0
04-Jul-07
|
|
| 276 |
|
#26366: Appendix A - 'tis' should be 'this'--Brian Riggs
|
P3.0
24-Oct-06
|
|
|
283 |
#25770: The code in the book for whitelists doesn't work. But the new code posted in the resources section:
http://fora.pragprog.com/rails-recipes/posts/show/127
does. I'm not sure why.--Jason L Michael (railsnoob) #25770: The code in the book for whitelists doesn't work. But the new code posted in the resources section:
http://fora.pragprog.com/rails-recipes/ ...more...
|
P1.0
22-Aug-06
|
|
| 287 |
321 |
#29185: A small error in the first sentence in paragraph A.2:
The source code in tis book...
Maybe right: The source code in this book...--Dave
|
P3.0
02-Jun-07
|
|
|
296 |
#27273: The code from notifier.rb as it stands doesn't work in the latest version of Rails because Rails automagically inserts the contents of multipart_alternative first (but without @name resolving) and then inserts the two parts as coded. This can be fixed by renaming multipart_alternative to multipart_alternative_html and altering the render_message accordingly.
This whole setup should have been tested on more than one (Mac-based) email agent. Google mail only displays the plain text section; Outlook only displays the HTML section.--Old Dog #27273: The code from notifier.rb as it stands doesn't work in the latest version of Rails because Rails automagically inserts the contents of multipa ...more...
|
P2.0
05-Mar-07
|
|
| PDF |
Paper |
Description |
Found in |
Fixed in |
| 1 |
|
#24427: For the section on html email. I saw in your source files that you do not have a css file or any images included. A slightly more advanced example will be immediately required by almost any reader. Complete paths are required for everything. Also the <link> and <head> tags have issues with email readers.
The use of layouts and templates are tricky too. See the Agile Rails book errata web page for a suggestion for page 415 (and 413).
see this link for details about what works in email readers
http://www.campaignmonitor.com/blog/archives/2006/03/a_guide_to_css_1.html
Something like
<html>
<body>
<style type="text/css">
@import url(http://www.domain.com/stylesheets/store.css);
</style>
<div id="main">
<img src="http://www.domain.com/images/logos/logo2-small.gif" />
<div id="popupMain">
<%= @content_for_layout %>
</div>
</div>
</body>
</html>
--Peter Michaux #24427: For the section on html email. I saw in your source files that you do not have a css file or any images included. A slightly more advanced exa ...more...
|
B1.3
08-Apr-06
|
|
| 6 |
|
#25325: Since you make a note stating to write your own actions for in-place edits, it would be nice to see at least one sample one. I'm having trouble locating a solution for this, and I'm not sure how to return a successful value or a custom error.
Another reason I mention this is because if someone uses an in-place edit field and updates it to an empty string, it becomes impossible to edit the field again, since there's nothing to 'click' to activate the edit mode. #25325: Since you make a note stating to write your own actions for in-place edits, it would be nice to see at least one sample one. I'm having troubl ...more...
|
P1.0
23-Jun-06
|
|
| 15 |
|
#24855: Hi
Using innerHTML here to add options to a select box won't work in, for example, IE6/win.
I would recommend adapting the recipe to use the new Ajax.InPlaceCollectionEditor (as of script.aculo.us version 1.5.3).
I've got some code if you want it: dave@textgoeshere.org.uk
Best,
D--Dave Nolan #24855: Hi
Using innerHTML here to add options to a select box won't work in, for example, IE6/win.
I would recommend adapting the recipe to use ...more...
|
B1.5
14-May-06
|
|
| 31 |
|
#24788: I suggest adding a Discussion entry to this recipe to explain why lists were used instead of tables. Due to browser incompatibilities sorting in tables isn't supported by Script.aculo.us (table row sorting works in Firefox for example but not in Safari). Thomas Fuchs could probably go into more detail about this issue.--Sean Mountcastle #24788: I suggest adding a Discussion entry to this recipe to explain why lists were used instead of tables. Due to browser incompatibilities sorting ...more...
|
B1.5
08-May-06
|
|
| 51 |
|
#24515: A suggestion for the discussion section of recipe 12 (Creating a custom form builder): In this section you mention meta-programming in Ruby and show some really cool examples of it. It suprised me because I never thought to even try stuff like that before. As a programmer who is learning Ruby through Rails, it would be helpful if the discussion included where to find out more information on meta-programming in Ruby and what it means. Or perhaps how one can get "under the hood" of Rails and try something similar to what you've shown.--Brian Chamberlain #24515: A suggestion for the discussion section of recipe 12 (Creating a custom form builder): In this section you mention meta-programming in Ruby an ...more...
|
B1.5
21-Apr-06
|
|
| 77 |
|
#24553: I'd like to see included in this recipe how one would prevent a person from adding oneself as a friend. For example, if Chad were to become a friend of Erik's, but Chad is such a nice guy that he instantly becomes a friend of all of Erik's friends, Chad would also become a friend to himself.
Person.find_by_name("Chad").friends << Person.find_by_name("Erik").friends
Is there a way to prevent that in the model without raising an exception with a before_add callback and thus pushing it off the controller to prevent?
Thanks!--Victor Cosby #24553: I'd like to see included in this recipe how one would prevent a person from adding oneself as a friend. For example, if Chad were to become a ...more...
|
B1.5
29-Apr-06
|
|
| 90 |
|
#24257: Recipe Suggestion: How to use LDAP/Active Directory for authentication only - integrate LDAP into Recipe 15 (Authentication) but also have it play nicely with Recipe 16 (Role-Based Authorization)--Tom Brice #24257: Recipe Suggestion: How to use LDAP/Active Directory for authentication only - integrate LDAP into Recipe 15 (Authentication) but also have it ...more...
|
B1.2
09-Mar-06
|
|
| 143 |
|
#24163: Near the bottom of the page, "|procmail" in an italic font makes the "|" look like a "/".
(Dave says: tricky to deal with this. Let me think about it)--Rob Biedenharn #24163: Near the bottom of the page, "|procmail" in an italic font makes the "|" look like a "/".
(Dave says: tricky to deal with this. Let me thin ...more...
|
B1.1
21-Feb-06
|
|
| 264 |
|
#25029: As the default behaviour of Rails in test mode is to append Email to an array, not actually send it, it might be an idea to briefly cover Email Configuration at the start of this chapter. Otherwise people might be confused when their HTML email never arrives in their inbox.--James Doy #25029: As the default behaviour of Rails in test mode is to append Email to an array, not actually send it, it might be an idea to briefly cover Emai ...more...
|
P1.0
25-May-06
|
|
| 268 |
|
#24575: Unfortunately the method described for graceful degradation of emails will not work for certain handheld devices, including the Blackberry's direct email inbox, which cannot handle multiple content types in the same email. You may want to mention this drawback.
(Chad says: I don't know the landscape here, and these are clients that don't support the standard properly.)--Henry #24575: Unfortunately the method described for graceful degradation of emails will not work for certain handheld devices, including the Blackberry's d ...more...
|
B1.5
02-May-06
|
|
| 281 |
|
#24769: Your example only produces a plain text e-mail. What if the user wants to send either an HTML email or a multipart/alternative email along with the attachment?--Dylan Markow #24769: Your example only produces a plain text e-mail. What if the user wants to send either an HTML email or a multipart/alternative email along wit ...more...
|
B1.5
06-May-06
|
|