Errata for Advanced Rails Recipes
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 P1.0,
released 11 days 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 |
| 73 |
|
#31852: Hi, there's a delete of a task from inside an iterator. I don't think that's safe, you'll not get to the end of the collection there. I had a collection of two objects where the first was deleted inside the iterator. The iterator never iterated over the second object. Better to collect an array of tasks_to_be_deleted and then call tasks.delete(tasks_to_be_deleted) once outside the iterator. Also, tasks are deleted a different step and not wrapped within the same transaction as the rest of the update when the after_update is called.--Tim Harding #31852: Hi, there's a delete of a task from inside an iterator. I don't think that's safe, you'll not get to the end of the collection there. I had a ...more...
|
P1.0
|
|
| 94 |
|
#31878: rescue and then just return false eats all exceptions (I for example had a type in the code), in my point of view this is very dangerous. Don't understand why you don't just track the status of the first save in a local variable?--Philipp Knobel #31878: rescue and then just return false eats all exceptions (I for example had a type in the code), in my point of view this is very dangerous. Don' ...more...
|
P1.0
|
|
| 117 |
|
#31675: DynamicMetaTags has this code which fails on IE:
def meta(name, content)
%(<meta name="#{name}" content="#{content} />" )
end
should be this (end quote incorrect)
def meta(name, content)
%(<meta name="#{name}" content="#{content}" />)
end
But why not use tag helper and be more railsy :-)
def meta(name, content)
tag("meta", :name => name, :content => content)
end--Tom Harrison #31675: DynamicMetaTags has this code which fails on IE:
def meta(name, content)
%(<meta name="#{name}" content="#{content} />" )
end
should ...more...
|
B1.06
|
|
|
147 |
#31886: After the two rake commands on the 4th & 5th lines of p147, it says:
"(If you're into shortcuts, these THREE Rake tasks..."
I believe the third rake task it is referring to is
"rake ultrasphinx:configure"
from two pages prior. But I can't be sure and it is very unclear.--Drew Blas #31886: After the two rake commands on the 4th & 5th lines of p147, it says:
"(If you're into shortcuts, these THREE Rake tasks..."
I believe th ...more...
|
P1.0
|
|
| 162 |
|
#31672: Keep Forms Dry, error_handling_form_builder.rb defines array of helpers; two are removed in the line "%w(label fields_for)" -- this should also include "hidden_field"
BTW -- this was a much needed recipe for my app. Now I need to figure out how to make it work for the scaffold generated "show" views, too :-)--Tom Harrison #31672: Keep Forms Dry, error_handling_form_builder.rb defines array of helpers; two are removed in the line "%w(label fields_for)" -- this should als ...more...
|
B1.06
|
|
| 291 |
|
#31680: In the first set of code examples on the page, a list of caching commands to execute through the console, in the last example of that section:
>> products = Product.related_products("barney")
>> ActionController::Base.cache_store.fetch("barney") { products }
=> [#<Product id: 21, ...]
The description of fetch just below this says: " When it doesn’t find your key in the cache,
it’ll run the block, save its results into the cache, and give them back
to you."
But in this case the Product#related_products method gets executed before the call to fetch which is then only passed the reference to the already loaded collection.
Should the correct way to handle this not look like:
ActionController::Base.cache_store.fetch("barney") do
Product.related_products("barney")
end
?
--Jesse Clark #31680: In the first set of code examples on the page, a list of caching commands to execute through the console, in the last example of that section: ...more...
|
B1.06
|
|
| 297 |
|
#31955: This recipe doesn't work. If I type Status::PENDING on the console, I always get a NameError: uninitialized constant Status::PENDING
Maybe it's because I'm using Postgres?--Lars Fischer #31955: This recipe doesn't work. If I type Status::PENDING on the console, I always get a NameError: uninitialized constant Status::PENDING
Maybe ...more...
|
P1.0
|
|
| 300 |
|
#31659: I still get the "can't Fixnum into String" error when loading a page with '?browser_profile!' appended to the URL.
This was reported for the previous version as #31189 where it is marked as fixed in B1.06.
The line apparently with the problem is:
controller.response.body << printer.print("", 0)
--Chris Stephens #31659: I still get the "can't Fixnum into String" error when loading a page with '?browser_profile!' appended to the URL.
This was reported for th ...more...
|
B1.06
|
|