By Developers, For Developers

Historical errata for Rails Recipes

PDF PgPaper PgTypeDescriptionFixed onComments
47SUGGEST

One: I don’t think you need to pass :layout => false when you render :partial in a controller. I think it assumes that for partials.

It seems like there could be some quick discussion on caching next to the one on db indexing too. Listing contacts + tags will give you n+1 queries which is not a good thing. Perhaps this could be a follow-up recipe on caching?

2006-04-19
36TYPO

Under Ingredients, command output of installation of acts_as_taggable plugin shows checkout of continuous_builder plugin.

2006-04-12
19TYPO

You’ll immediately notice that RJS implicitly supplies and object

“and” should be “an”

2006-04-12
9TYPO

> element’ should read ’

element’

2006-04-12
99SUGGEST

The text speaks about line numbers - “Then,
on lines 8 and 11,” …., however, the code does not contain line numbers - they really would help.

2006-04-12
59ERROR

The self.down method is missing:

drop_table :rights_roles

The complete method should be:

def self.down
drop_table :roles_users
drop_table :roles
drop_table :rights_roles
drop_table :rights
end

2006-04-20
60SUGGEST

The check_authorization method uses right.controller == controller_name when checking the right. This can lead to incorrect authorization when using sub controllers.

I use sub controllers often in the projects I work on i.e.
Admin::ArticlesController < ApplicationController which generates urls like http://example.com/admin/articles.

The controller_name method returns “articles” leaving off the full class name in this case. The problem is that I may also have a different controller named ArticlesController < ApplicationController and from the rights perspective both return “articles” which can lead to incorrect authorizations.

I’ve solved this by changing right.controller controller_name to right.controller self.class.controller_path.

self.class.controller_path returns “admin/articles” which is the full controller name I am interested in.

Not sure if you want to add a note to this recipe or just change it to use self.class.controller_path which will work in all instances.

2006-04-20
11ERROR

The bookmarks for each recipe are erroneously nested under the first recipe of each chapter.

2006-03-15
11SUGGEST

Recipe suggestion: Using Erb to simplify database.yml (e.g. same login, database name prefix, host for each environment)

2006-04-12
53SUGGEST

I think the section titled “Convert an Existing Application to Migrations” isn’t properly descriptive. Sure, it tells you what it does, but the average reader who doesn’t know what Migrations does wouldn’t know why they want to use Migrations. It should explain what they’re for, e.g. “Manage Your Database Schema Using Migrations.”

2006-04-19
27TYPO

“When a Rails application boots, it loads its config/environtment.rb file.”.sub(/environtment/, “environment”)

2006-04-12
39TYPO

In the Tagging extract, the div with the id “contact-<contact.id>” is replaced with the contents of the partial “content”. The problem is that the partial content itself contains that same div with the id “contact-<%= contact.id“, thus resulting in recursive divs which, second time around, confuses javascript (there are now two divs with the same id, what to do?). The solution is to move the container div with the id ”contact-<=contact.id%>” outside of the partial “content” (into the partial “detail”).

2006-04-20
11TYPO

In the first paragraph: “This is all standard ActiveRecordhas_many( ) fare,”.sub(/ActiveRecor(dh)as_many/,‘ActiveRecord#has_many’)
Or perhaps a space.

2006-04-12
12TYPO

Indentation of the second example looks off (the lines look indented too much)

2006-04-17
6SUGGEST

This seems like it would be a good place to use a partial and maybe even rjs.

It may be beyond the scope of this example, but guiding the user to use partials here to make use of the same code as is used to generate the final entry seems very DRY.

2006-04-12
14ERROR

It doesn’t seem like your “raise params.inspect” in #sort was supposed to be there. If it was, I would expect it to be referenced somewhere. (It is one way to deal with understanding output, but it isn’t completely obvious to the casual observer)

2006-04-12
3SUGGEST

A recipie for continuations/wizards would be nice to see.

2006-04-12
23TYPO

The last two paragraphs “Some digging shows that…” seem to be different version of the same thought.

2006-04-12
87SUGGEST

http://damagecontrol.codehaus.org/ redirects to a new location, you might want to update the URL.

2006-03-16
54SUGGEST

In the ‘check_authentication’ method you’re storing the name of the requested action in the session[] hash. If the action also has a corresponding set of @params associated with the request, it appears like that will be lost once the user logs in. So if they were following a link that was supposed to display all users matching a certain critera, (Admin#display_users), that criteria will be lost upon log in.

In the check_auth method, can you also store the accompanying params associated with the action, to be re-accessed after log in?

2006-04-20
11ERROR

acts_as_list :scope => :grocery_list_id

You should use ‘grocery_list_id’ or :grocery_list. When you pass a symbol, it adds _id.

From the API docs for acts_as_list:
scope - restricts what is to be considered a list. Given a symbol, it’ll attach “_id” (if that hasn’t been already) and use that as the foreign key restriction. It’s also possible to give it an entire string that is interpolated if you need a tighter scope than just a foreign key. Example: acts_as_list :scope => ‘todo_list_id = #{todo_list_id} AND completed = 0’

2006-04-17
33OK

Self-referential Many-to-Many Relationships:
1. The link table might have additional attributes. Show how to use them. For example with push_with_attributes method.
2. There is no model generated for the link table. Show how to create fixtures for it and how to load fixtures in correct order so DB referential integrity checks are satisfied.

2006-04-12
69SUGGEST

I was surprised at the suggested way to write fixtures out from data currently in the database. It doesn’t seem like that rails way to drop right down to the database connection and run sql queries! A much better way (in my opinion, at least) is described here: http://rails.techno-weenie.net/tip/2005/12/23/make_fixtures (see comments 9 and 10).

Basically, you just add a to_fixture method to ActiveRecord::Base and then run it for each model class. Person.to_fixture, Club.to_fixture etc… simple!

Cheers, Jonathan.

2006-04-19
7ERROR

In the PDF version, the Bookmark hierarchy is messed up. Under each of the main Recipe chapters, only one recipe appears, with the remaining recipes appearing under the first recipe. So Live Preview incorrectly appears to be the parent of Live Search.

2006-03-15
12TYPO

Last paragraph:
“As always, if you’re going to do fancy Ajax stuff, you need to make sure you’ve include the necessary JavaScript”

include -> included

2006-04-12
41TYPO

2nd paragraph, 2nd sentence: “Since we already the list( ) action, it makes sense to modify it for our needs instead”.
Missing ‘created’ or ‘have’ after ‘already’

2006-04-19
112TYPO

In the Thunderbird box at the top of the page, it says “…you can download Firefox (http://www.mozilla.com).”, when it should read “…you can download Thunderbird (http://www.mozilla.com/thunderbird/).”

2006-03-16
87TYPO

In the first paragraph under the Solution header, third sentence, you have, “… is a simple Rake tasks that gets executed …”. The word “tasks” should be “task”.

2006-03-16
62TYPO

“We then created a Right called Create Recipes and added it to the list of rights afford to our freshly created Role.”

I think “afford” should be “afforded”.

2006-04-20
6054TYPO

“But for now, we’ll just create when using
the Rails console.”

should read…

“But for now, we’ll just create one using
the Rails console.”

2006-04-20
2SUGGEST

If you’re still soliciting for recipe requests, I’d really like to see a better treatment of ‘sidebar’ plugin type modules… sort of like how Typo has pluggable sidebar modules. The Agile book touches on them but not very concretely.

2006-04-12
33OK

Self-referential Many-to-Many Relationships:
3. Here http://wiki.rubyonrails.org/rails/pages/Update+has_and_belongs_to_many+Attributes
is a nice plugin which allows to update a link table attributes. Worth showing it.
4. Somewhere I’ve found an example (below) which shows that you can use more than one has_and_belongs_to_many statement in your class to certain table. Instead of retrieving all visits, the code below selects only today’s visits which is quite good optimization.

class Task
has_and_belongs_to_many :visits
has_and_belongs_to_many :visits_today,
:class_name => ‘Visit’,
:join_table => ‘tasks_visits’,
:associated_foreign_key => ‘visit_id’,
:conditions => [“visits.created_at BETWEEN ? AND ?”,
Time.now.midnight, Time.now]
end

2006-04-12
54TYPO

But for now, we’ll just create when

- should be -

But for now, we’ll just create one

2006-04-19
54TYPO

In the following text, the comma following the word “passwords” is not needed.

“Since we don’t want to store plain-text passwords, in the database, we
use Ruby’s MD5 library to create a hash of the plain-text password for
storage.”

2006-04-19
106TYPO

You recommend firefox as email client….thunderbird is probably better ;-)

2006-03-16
59ERROR

In the code
def self.down
drop_table :roles_users
drop_table :roles
drop_table :rights
end

you haven’t dropped the table :rights_roles

2006-04-20
1SUGGEST

Recipe suggestion: A recipe on how to upload a file to a rails application, with a progress meter would be nice.

2006-04-12
37SUGGEST

Dear Sir,

This is NOT an error report, just a request.

I’d love to get more information on polymorphic associations (ie a better and more general picture than acs_as_taggable).

Thanks and best regards,

Tobie

2006-04-20
1SUGGEST

Recipe suggestion: A couple of recipes on sharing code between different rails applications. (plugins, engines, sharing with svn:externals,..)

2006-04-12
39ERROR

I know this is not related to the book’s topic but the code you show on your contacts/list.rhtml page is not standard compliant.

If there is no contacts to display, the list will not contain any list elements (

  • ) and the page would thus not validate.

  • 2006-04-19
    37ERROR

    If this is true:

    “Whatever you do, IT IS ABSOLUTELY IMPERITIVE that you setup the tags database with the field `name`. This has to do with the fact that internally, acts_as_taggable uses a find_by_name method, which does not exist if there is no name column in the tab” (source: http://quirks.exposured.com/?p=6)

    then you should definitely report it.

    2006-04-20
    8SUGGEST

    I’d suggest making this chapter more detailed. There is more information here:
    http://wiki.rubyonrails.org/rails/pages/How+to+make+a+real-time+search+box+with+the+Ajax+helpers

    2006-04-12
    53SUGGEST

    The authentication recipes are cool, but it would certainly be nice to have an example that shows how to expire logged in users, etc..

    2006-04-19
    52DEFER

    I would love a recipe on how to create totally seperate accounts for an application, i.e. like Ta-da list.

    2006-04-20
    103TYPO

    Under Solution:

    “There are test harnesses in place to see access all of the mail you’ve sent with ActionMailer,”

    Remove “see”.

    2006-04-12
    103TYPO

    End of second paragraph under Solution:

    “An simple example .for-ward file might look like the following.”

    Should be “A” not “An”.

    2006-03-16
    105TYPO

    Towards the end of the first paragraph under the code examples:

    “Namely, we can store each message in a text file under application’s test/fixtures/receiver directory.”

    Perhaps “our application’s” or “the application’s”?

    2006-03-16
    107TYPO

    End of first paragraph after the successful test:

    “We won’t look at the details of the data model here, but just keep in mind that we have a model named Mail (with a cor-responding mails table) that has the expected subject( ), body( ), sender( ), etc. attributes as we as a numeric rating( ) attribute.”

    End of sentence, should be “as well as” instead of “as we as”.

    2006-03-16
    30TYPO

    Last paragraph before class AddProductReferenceTable (end of page):

    “To make the connection, we’ll create a mapping table in our applica-tion’s default database (the same one the cart table exists ins):”

    Should be “exists in” and not “exists ins”.

    2006-04-12
    65TYPO

    The YAML file listed (File 38) has duplicate ‘created_at’ fields for records 2 & 3 - whereas #1 has ‘created_at’ and ‘updated_at’… the error is present in the file (File 38) as well, though not consistently.

    2006-04-20
    106TYPO

    Sentence in Thunderbird box: “If your client doesn’t do give you the option of view a message’s source,” should be: “If your client doesn’t give you the option of viewing a message’s source, ”

    2006-03-16
    50SUGGEST

    A “further reading” section pointing at the documentation for migrations would be a really useful addendum here.

    http://api.rubyonrails.org/classes/ActiveRecord/Migration.html

    Other useful links might be:

    http://www.robbyonrails.com/articles/2005/11/11/rails-migrations-and-postgresql-constraints

    Which shows how to extend migrations using ordinary SQL, something that people are pretty likely to want to do.

    2006-04-20
    56ERROR

    It is not explained why an exception is thrown and how it could/should be catched.

    2006-04-21
    24TYPO

    ‘and’ should be ‘an’

    “You’ll immediately notice that RJS implicitly supplies and object called page which provides all of the JavaScript generation methods.”

    2006-04-12
    54TYPO

    The color of the second line should be red, not blue.

    chad> ruby script/runner ‘require “active_record/schema_dumper”;
    ActiveRecord::SchemaDumper.dump’

    2006-07-03
    10599OK

    These lines probably need = signs.

    subject “Something for everyone.”
    recipients recipient
    from ‘barnam@chadfowler.com’
    sent_on sent_at
    content_type “multipart/alternative”

    (Dave says: actually, they’re ok)

    2006-03-16
    54SUGGEST

    Should this recipe recommend the use of Digest::SHA1 instead of MD5? It appears that MD5 is regarded as slightly weak these days, so it’s probably a good idea to propogate “best practise”.

    More info: http://www.schneier.com/blog/archives/2005/06/more_md5_collis.html

    2006-04-19
    41SUGGEST

    This discussion left me somewhat confused, wondering why there was never any mention of Tag or Tagging AR classes, nor of scoping Tags with something like “acts_as_taggable :scope => :account” like you might with acts_as_list.

    2006-04-20
    1SUGGEST

    Please add some unicode(i18n) recipes. Thanks

    2006-04-12
    1SUGGEST

    Two recipe suggestions: (1) dynamically handling 404 errors in conjunction with the ExceptionNotifier and (2) establishing subdomain-based accounts.

    2006-04-12
    51ERROR

    The “alternative way” of making the initial migration work by inserting version “1” into the schema_info did not work for me using SQLite3. The same ‘table exists’ error showed up when running rake migrate. But then I looked at the contents of the schema_info table. There were two rows, with 0 and 1. I ran “DELETE FROM schema_info WHERE version=‘0’” and reran rake migrate, and all was well.

    2006-04-20
    99TYPO

    The grammar of the first sentence of the Solution is broken. It looks like the word “that” is missing before “is designed”.

    You may also wish to include a VERP recipe (using per-recipient envelope sender addresses to distinguish the recipient from which a bounce originated).

    2006-03-16
    39TYPO

    The first code snipped (File 46) is missing a final end statement.

    2006-04-21
    71TYPO

    Kelly and James shouldn’t be indented in the YAML.

    2006-04-20
    37SUGGEST

    I agree that more information about polymorphic associations would be a great idea. Additionally, one of the great features of acts_as_taggable is that it is polymorphic, you could extend your example to demonstrate this.

    2006-04-20
    12TYPO

    4th non-code paragraph, 15th word: should be retrieved, not retried.

    “And each GroceryList has a list of FoodItem objects on it, which will be retried by the food_items table’s position column.”

    2006-04-12
    51SUGGEST

    In many cases, it’s a fair bit of trouble to get your initial schema into ruby format. In the early phases, I prefer to create a regular sql script to drop/add all the initial tables and database objects. At some later point, when other devs come on board or perhaps I have some test data I like, I declare the current schema to be version 0, and start using AR migrations from that point on. When someone else joins the project, they run the ‘create’ script to get to version 0, then run ‘rake migrate’ to do the rest. Letting ‘rake migrate’ fail, then manually setting VERSION=1 seems a bit inelegant to me.

    2006-04-20
    1SUGGEST

    I definitely agree with the RJS recipe idea, having rjs recipe(s) would be great. Maybe one recipe covering the basics of rjs, and another recipe which has an advanced real-world example of rjs at use. Also, a few more advanced real-world database recipes would be wonderful. Basically the two things I really want to see alot more of is AJAX and advanced databases. Anyways, I’ll be looking forward to all future releases, thanks for the wonderful book.

    2006-04-12
    143DEFER

    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)

    139TYPO

    he => the, in “we add additional parts to he message,”

    2006-03-16
    139TYPO

    Bottom paragraph refers to lines by numbers, but there are no line numbers.

    2006-04-17
    149TYPO

    In the text “Hey bro, I thought you’ d like to see this. It’ s the latest new”, the text between single quotes is rendered in italics.

    2006-04-19
    124TYPO

    know => knowing in “we need two things: some way of
    know what”

    2006-03-16
    51TYPO

    The output from “chad> ruby script/plugin install acts_as_taggable” is actually the output of “chad> ruby script/plugin install continuous_builder”

    2006-04-19
    8TYPO

    In the last sentence of the last paragraph on this page it reads:

    “May Rails helpers accept additional…”

    It should read:

    “Many Rails helpers accept additional…”

    2006-04-12
    32SUGGEST

    A suggestion for the multiple databases recipe: please add a solution to how to go about testing with two databases. I posted a possible solution to the RoR list, but maybe there’s some better way:

    in the model:

    <code>
    if ENV["RAILS_ENV"]=="test"
      Person.establish_connection "db_test"
    else
      Person.establish_connection "db"
    end
    </code>

    in the test - instead of “fixtures :people” something like this:

    <code>
    Fixtures.create_fixtures(File.dirname(__FILE__) + "/../fixtures",
    ["people"]){Person.connection}
    </code>
    2006-04-12
    1SUGGEST

    Suggestion: example of non-trivial lookup pattern. For example you might want to lookup a person out of a list of thousands. So you want to query the list first with a few parameters (eg age, name, etc), and then select one from the matching records. Usually a pop-up window is used for the lookup. How can this be done in the Rails way?
    An example can be found in Yahoo email. When composing an email, you can either type in the name of the recipient (with AJAX autocompletion), or you can click on a link to select a name from your address book. This brings up a new window. See also the mailinglist thread http://www.ruby-forum.com/topic/52767 This thread addresses the same problem, but no solution.

    2006-04-12
    1SUGGEST

    Suggestion: how to implement a single-language (but not English) application. No need for Globalize, but how do you override the built-in Active record messages, which are in English.

    2006-04-12
    56SUGGEST

    It is likely that you need the authentication on several controllers, not just one. In this case, you might want to suggest WHERE to put the logic then.

    2006-04-20
    58SUGGEST

    This chapter could really use a table diagram (or UML Class diagram), showing the tables, columns and relations. Something similar to the diagrams in chapter 14 of AWDR.

    2006-04-20
    73TYPO

    “A (n) Author can have many Books”

    2006-03-16
    149TYPO

    Second phrase under Solution heading: “There are test harnesses in place to see access all of the mail you’ve sent with ActionMailer.”

    …“see access”?

    2006-03-16
    143TYPO

    The typo I reported to be on page 149 is actually on page 143 . My PDF reader is reporting them differently. Blah Linux (I imagine my previous submissions were off too)

    The typo was “see access” in the second phrase of the Solution heading.

    2006-03-16
    80TYPO

    Text, emphasis mine: But for now, we’ll just create when using the Rails console.

    I’m pretty sure you that should be “one”.

    Keep up the good work.

    2006-03-16
    130TYPO

    Last word of first paragraph following code is ‘actionwebservicea’.

    2006-03-16
    20SUGGEST

    This section should be called Auto Complete and have a different section called Live Search that involves performing a live search and showing those results on the page.

    2006-04-19
    84SUGGEST

    The ‘role based authentication’ chapter could benefit from the ‘Many to Many Relationships Where the Relationship Itself Has Data’ chapter…
    to achieve a fine granularity while controling the access to an app it’s important to define the roles the user can gain access to but also the datas the user can access….we can imagine a user with an editor access to one article but not to an other one….why don’t you mix these 2 chapters to add data to the roles/users many to many relationship.

    (Dave says: The author says that this is an interesting extension, but would make the recipe too long.)

    2006-03-16
    89ERROR

    In the signout method’s redirect, home_url isn’t defined unless there is a map.home line in routes.rb (not the default).

    2006-04-12
    107TYPO

    Last sentence of the first paragraph of the “Solution” reads:
    “Continuous Builder plugin is a simple Rake tasks that”

    it should read:
    “Continuous Builder plugin is a simple Rake task that”

    2006-03-16
    88TYPO

    In the first paragraph:
    Second sentence: #2431 still applies.
    Last sentence reads:
    “Since the Create RecipesRight grants…”
    there should be a space between ‘Recipes’ and ‘Right’

    2006-03-16
    90TYPO

    “Solution”, first paragraph, first sentence reads:
    “An often-overlooked feature of the way Rails deals fixture files…”

    I think should read:
    “An often-overlooked feature of the way Rails deals with fixture files…”

    2006-03-16
    92TYPO

    Second paragraph, second sentence should end with a question mark:

    “Now what if we wanted to do something smart with the
    dates(?)”

    2006-04-12
    118TYPO

    Second to last paragraph: “Finally, line declares the upload( ) task to” => “Finally, the last line declares the upload() task to” or “Finally, line 18 declares the upload() task to”

    2006-03-16
    39ERROR

    Recipes 8-14 show as sub bookmarks of recipe 7 instead of the Part II: Database Recipes bookmark

    2006-03-15
    76TYPO

    First paragraph reads:
    “…populates both the addressable_idand the…”
    There should be a space between ‘addressable_id’ and ‘and’

    2006-03-16
    57SUGGEST

    Apparently there is a way to get acts_as_taggable to work with multiple users by adding user_id to the join table. It would be nice if you could cover this. I imagine most implementations will need support for specific tags for individual users.

    2006-04-20
    4TYPO

    “script.acluo.us” should be “script.aculo.us”

    2006-03-16
    8SUGGEST

    “What I did was I created” sounds pretty unpleasant. It might be better to use “What I did was to create” instead, or you could just delete the redundant “What I did was” altogether.

    2006-04-12
    80SUGGEST

    Using un-salted passwords is a situation ripe for abuse. It creates a situation where dictionary attacks are trivial to mount against an application. While I realize that the goal is to provide a framework, I’d recommend adding salting to the framework. I can provide all the code for doing so if you want to include it, including random salting so that no single salt is used. This is a major failing in SaltedLoginGenerator — fixed salting.

    Also, as someone else mentioned, MD5 has collisions, and more and more being discovered. SHA1 also has a few, but they are much harder to create. I don’t know what the exact probability is with a password-sized datum, but SHA1 is certainly less likely to do so.

    2006-04-12
    10TYPO

    First paragraph in Solution: “script.acluo.us” => “script.aculo.us”

    2006-04-12
    13TYPO

    In the last paragraph, “app/vies/contacts/demo.rhtml” should be “app/views/contacts/demo.rhtml”.

    2006-04-12
    35SUGGEST

    Would be nice to know how to use table_name_prefix in a shared host environment to create different sets of tables for dev, profuction, and testing where user has access to only one database.

    2006-04-12
    135OK

    On OS X with a working svn install, the line:

    svn propset svn:externals “rails http://dev.rubyonrails.org/svn/rails/trunk”

    results in a:
    svn: Explicit target required (‘rails http://dev.rubyonrails.org/svn/rails/trunk’ interpreted as prop value)

    (Dave says: youre missing the final ‘.’)

    2006-03-16
    33SUGGEST

    RJS seems to need EdgeRails since not included in Rails 1.0
    Maybe including some links like http://wiki.rubyonrails.com/rails/pages/EdgeRails should be wise

    2006-04-12
    8680ERROR

    I second the suggestion about MD5, but I make it more emphatic. No new applications should be using MD5, period. Any type of use that is even tangentially related to security should not rely on the non-collision features of MD5, since they have been repeatedly demonstrated to be broken. Even if you are using MD5 in a way that you do not think involves security, there are often subtle ways that your application can be exploited that might be overlooked. It is best to go with SHA-256, or barring that, SHA-1, which is showing signs of wear but still secure given today’s computing power.

    2006-04-12
    129SUGGEST

    Some help on installing edge rails for Windows

    2006-04-12
    29OK

    in the Indgredients list you should put:
    Rails 1.0 w/ rjs plugin (javascript_generator_templates located at: http://www.codyfauser.com/svn/projects/plugins/javascript_generator_templates/)
    or
    Rails 1.1

    2006-04-12
    85ERROR

    def self.drop doesnt drop the rights_roles table

    2006-03-16
    1SUGGEST

    Write about web analytics with rails
    http://rails-analyzer.rubyforge.org/

    2006-04-12
    80TYPO

    To add to the above, you can salt with the username, which adds no extra columns to the Users table.

    2006-04-12
    10SUGGEST

    “One of the things I love about Rails is that, though I enjoy taking advantage of many of the user inter face benefits that JavaScript provides, I really don’t like writing JavaScript code.” Skip the part between commas and this phrase becomes: “One of the things I love about Rails is that I really don’t like writing JavaScript code.” which doesn’t read right.

    2006-04-12
    9SUGGEST

    In-place form editing is cool, but I notice (unless I have made a silly error) that validators are bypassed when this technique is used. I suggest that this caveat of inplace editing is included in the discussion, or ideally that a fix or workaround is included in the recipe.

    Many thanks and keep up the good work!

    2006-04-17
    41ERROR

    Self-referential many-to-many:
    the example as given didn’t work when trying to delete a friend: it ends up in an endless loop where a friend tries to delete a friend tries to delete a friend etc.
    If fixed it as followes:

    def no_more_mr_nice_guy:
    begin
    if friend.friends.find(self)
    friend.friends.delete(self)
    end
    rescue ActiveRecord::RecordNotFound
    end

    2006-04-20
    1SUGGEST

    Juggestion for a recipe: how to load tons of data into the database.
    Try adding just 1500 records in a table and it currently takes ages on a standard MySQL installation.

    - 150 seconds if you do it create by create
    - 120 seconds if you create a list with hashes and do a single create. Internally, ActiveRecord just breaks it up in to individual creates.

    After a lot of searching in the source, I now simply create a pure SQL string that adds everthing in one go. Take 0.3 seconds. :-)

    I use

    ActiveRecord::Base.connection.execute(“insert into my_table values (null, ), (null, ), … ”)

    but there’s probably a better way to do it. It’d be nice to see a recipe about it.

    2006-04-12
    1SUGGEST

    Recipe idea: combine the many-to-many and polymorphic recipies into a user/group authorization authorization framework.

    2006-04-12
    86SUGGEST

    My taste in OO is to move the code starting with user.roles.detect to the User object as a has_right method. This keeps the code cleaner in the Controller and places the logic where it belongs, I think.

    2006-04-19
    20ERROR

    First, this isn’t a “live search” it is an autocomplete restricted to one colomn in one table. Second, to get it to work, you need to add the auto_complete_for :recipe, :name at the beginning of the recipe controller.

    2006-04-19
    102TYPO

    Last paragraph: “…a generator is laid out as in as shown in Figure 1.2” - this should be: “…a generator is laid out as shown in Figure 1.2”

    2006-04-12
    86SUGGEST

    The indentation of check_authorization seems odd. Is this simply a rubyism to deal with blocks in conditionals?

    2006-04-12
    86OK
    1. one small change to allow a right to be controller-wide
    2. simply by not specifying an action

    right.controller controller_name && (right.action action_name || right.action.nil?)

    2006-04-12
    80SUGGEST
    1. putting the MD5 encoding into the model follows DRY
    2. Much easier to type:
    3. user = User.create(:username=>‘mike’, :password=>‘blah’)

    class User < ActiveRecord::Base
    validates_uniqueness_of :username
    has_and_belongs_to_many :roles

    require ‘digest/md5’

    def password=(password)
    write_attribute(“password”, MD5.md5(“secretpassword”).hexdigest)
    end

    2006-04-12
    92SUGGEST
    1. redirect on login breaks when user requested a controller # other than the one with the auth pages
    2. storing session[:intended_controller] and using this when
    3. the user logs in fixes this

    def check_authentication
    unless session[:user]
    session[:intended_controller] = controller_name
    session[:intended_action] = action_name
    redirect_to :controller => ‘admin’, :action => “signin_form”
    return false
    end
    end

    2006-04-21
    55SUGGEST

    Nowhere on this page does the author explain where this piece of HTML should go, nor is there any explaination given of how a person could convert this to be used with a default application controller to provide security for all of the pages in an application except for the login screens and such.

    2006-04-20
    90DEFER

    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)

    190OK

    Page 190 describes how to get the source code:

    Rails Recipes Home Page
    pragmaticprogrammer.com/titles/fr_rr
    Source code from this book, errata, and other resources. Come give us feedback, too!

    There is no source code avaialble on that page.

    2006-04-12
    160TYPO

    “have become a first-class citizens” -> “have become first-class citizens”

    2006-03-16
    82SUGGEST

    In the ‘extending associations’ recipe, it might be a good idea to mention the implicit way of extending the functionality of AR associations: add a class method to the associated model. This will achieve the same effect, if you’ve got a method that is useful outside the association as well. Following the example scenario in the recipe:

    class Student < AR::Base
    has_many :grades
    end
    class Grade < AR::Base
    def self.below_average
    find(:all, :conditions => [‘score < ?’, 2])
    end
    end

    This would allow Grade.below_average in addition to Student.find(:first).grades.below_average.

    2006-04-12
    99ERROR

    At the end of the page the next mapping is created on routes.rb:

    map.connect ‘popular/:tag’ , :controller => ‘recipes’,
    :action => ‘list’ ,
    :tag => ’’ ,
    :filter => ‘popular’

    And the text says:
    “First, you’ll notice that if you put this rule above the existing routes in routes.rb, the wrong parameters get populated”

    The correct text should say:
    “…if you put this rule under the exisiting routes…”
    for the rules to work properly

    2006-03-16
    47TYPO

    "YAML has a little-used feature called “merge keys

    2006-04-19
    80TYPO

    “Student class has_many( )Grades.” >> Needs space before Grades

    2006-03-16
    82ERROR

    No bookmark for the new Dynamic Database Config chapter.

    2006-03-15
    74ERROR

    The example code near the bottom only works if you haven’t run ‘rake migrate’ first, since it insert another record into schema_info instead of changing the value of row one. For the tutorial to work as written, replace the Insert statment with an update one like this:
    “UPDATE schema_info set version = 1”

    2006-04-20
    158ERROR

    No Bookmark for “Quickly Inspect Your Sessions’ Contents”

    2006-03-15
    74SUGGEST

    It would be nice to have a few references to where to go to learn more about migrations.

    2006-04-19
    152SUGGEST

    It’s probably worth adding a mention about “conditional GET” and If-Modified-Since headers in the Discussion section. Once you serve up feeds, you tend to find that the feed readers will hammer your server. Conditional GET can really lighten the load. I got my implementation from: http://manuals.rubyonrails.com/read/chapter/62 — it was easilt adapted to my Atom feed.

    2006-04-20
    4TYPO

    You have a spelling error: script.acluo.us (line 5) should be script.aculo.us

    2006-03-16
    98OK

    in the extract_fixtures script, changing the
    hash[“#{table}#{i.succ!}“] to
    hash[”#{table}
    #{record[‘id’]}”]
    will make sure the yaml names correspond to the id of the record in the database. That way you can look up the fixture corresponding to a particular database record easily.

    (Chad says: I don’t really want people to get into the habit of thinking the fixture keys are somehow linked to the record id - no change)

    2006-04-17
    50DEFER

    There is a code snippet on this page. The actual code is colored blue and the result is considered to be colored green. If the result is more than one line, the text color is blue (but it should green). It occurs on several other pages, too.

    (Dave says: the ‘#’ character confuses our syntax highligher, making it color the line as a comment. Kinda hard to fix.)

    2006-07-03
    vOK

    The line is too long and throws out the contents numbering.
    How about removing “Where the Relationship Itself Has Data” and leaving it as Many to Many Relationships?

    (Dave says: we deal with this kind of stuff during layout.)

    2006-03-15
    165OK

    The link extends off the page. Also the page is missing the report erratum off the bottom.

    (Dave says: we fix these kinds of issues when doing the final layout)

    2006-03-15
    1TYPO

    Receipe 17 and 32 are not listed in the content pages

    2006-03-15
    8TYPO

    The last sentence on tha page starts with: “May Rails
    helpers accept additional parameters that will be passed directly”

    I think the first word should be Many and May.

    2006-04-12
    1SUGGEST

    Editing associated objects in the same form.
    exemple: people has many phones with one form where u want to create a new person and a few associated phones…at once.

    2006-04-12
    95TYPO

    The text says “after two minutes” but the code has “10.minutes.from_now”.
    Perhaps s/two/ten/

    2006-03-16
    13ERROR

    app/views/contacts/demo.rhtml

    Span requires a class to work.

    Some Value

    2006-04-19
    17TYPO

    Typo is now located at: http://www.typosphere.org/

    2006-04-12
    17OK

    layouts/standard.rhtml
    should be
    layouts/application.rhtml

    2006-04-12
    87ERROR

    conditions for name and password should include quotes around them:
    :condition => ["userame = ‘?’ AND password = ‘?’, …, …]

    Additionally, MD5.hexdigest(foo) is a little easier than MD5.md5(blah).hexdigest.

    2006-03-16
    86OK

    on the part where you use the Rails console to create a user..
    >> require ‘digest/md5’
    => true

    should say:

    => false

    That’s what mine does anyway.
    (Dave says: That just means you already have it loaded)

    2006-03-16
    71ERROR

    In recipe 14 “MTM Relationships where the Relationship…”, your Subscription class belongs_to associations should be singular, not plural.

    class Subscription < ActiveRecord::Base
    belongs_to :reader
    belongs_to :magazine
    end

    2006-04-17
    65TYPO

    3rd paragraph: “After require()’ing active_record/schema_dumper (it’s not loaded by Rails by default), a call to ActiveRecord:SchemaDumper.dump() will result in your default database’s scheme being dump to your console.”

    I think that should end “being dumped to your console.”

    2006-04-20
    115TYPO

    Last paragraph reads: “By convention, a generator is laid out as in as shown in Figure 1.3 .”, should read: “By convention, a generator is laid out as shown in Figure 1.3.”

    2006-03-16
    129SUGGEST

    The proper debugging/check for the post-commit hook is described in the Subversion FAQ - http://subversion.tigris.org/faq.html#hook-debugging

    2006-04-12
    14SUGGEST

    Shortcut :)

    in_place_editor_options[:url] ||=
    url_for({ :action => “set#{object}#{method}”, :id => tag.object.id })

    2006-04-12
    1SUGGEST

    I have been working on making a self-referential habtm relationship
    that uses a join model because I want to store info about the
    relationship. I have been using two sections from Chad Fowler’s “Rails
    Recipes” as a guide, “Self-referential Many-to-Many Relationships” and
    “Many to Many Relationships Where the Relationship Itself has Data”.
    So far I have had little luck.

    2006-04-12
    81TYPO

    on text for including module in model:
    says:
    “require ‘lib/grade_finder’”

    It would only work for me if I did the following:
    “require ’../lib/grade_finder”

    2006-04-12
    56TYPO

    extraneous close tag in the javascript_include_tag example

    2006-04-20
    173TYPO

    Just a little typo: “…send and receiver simple….” —> receive

    2006-04-12
    176 / 182TYPO

    Beginning of last paragraph for “Secret URLs” reads like: “The URL for our the feed for inbox number 5 […]”

    2006-04-12
    45TYPO

    The last paragraph says “he’ll see be confronted with …”, should say “he’ll be confronted with …”

    2006-04-20
    182ERROR

    There is a breakpoint in the authenticate_access_key method

    2006-04-12
    35ERROR

    The ERb code to generate the Javascript does not work if someone’s name has an apostrophe. Using double quotes instead of single quotes will allow us apostrophe-saddled folks back in the game.

    2006-04-12
    142TYPO

    The phrase that reads “…and in the background an email like the on in Fig-
    ure 1.5,…” should be “…and in the background an email like the one in Fig-
    ure 1.5, …”. Note the change from ‘on’ to ‘one’.

    Thanks.

    2006-04-12
    140ERROR

    Recipe 31 entitled “Getting Notified of Unhandled Exceptions” requires Rails 1.1 as of Rails Changeset 3900 from earlier today (http://dev.rubyonrails.org/changeset/3900). This Changset modified plugins/exception_notification/lib/exception_notifiable.rb to use the new respond_to API which was added in Changeset 3838 on March, 11th. The result of running the code in the recipe in a non-1.1 system is NoMethodError in #boom: undefined method ‘respond_to’ in /vendor/plugins/exception_notification/lib/exception_notifiable.rb:64.

    If you installed the exception_notification plugin prior to today, however, you’d probably be OK.

    If there are any questions, please let me know.

    Thanks.

    Steven Smith
    ssmith@fiveruns.com

    2006-04-12
    25TYPO

    In the second to last paragraph, before that code sample, you have the sentence:

    “As always, […] make sure you’ve include the necessary […]”

    It should say

    “…make sure you’ve included…”
    ^

    No typos found till then so far. And usually I catch them all ;-)

    Philip

    2006-04-12
    146TYPO

    “processed aftermusicians.csv’s last update.”

    Needs space before “musician.csv’s”.

    2006-04-12
    131SUGGEST

    “, before we perform the upload, we need to make sure musicians.xml is up to date”

    Could you give a few more details about where/how is check takes place in the example?

    What is this line doing exactly:

    “file ‘musicians.xml’ => ‘musicians.csv’ do |t|”

    and why isn’t it defined using the ‘task’ keyword like the other task:

    “task :upload => ‘musicians.xml’ do |t|”

    2006-04-17
    39TYPO

    “he’ll see be confronted with
    the usual page”

    “see” or “be confronted with” (not both).

    2006-04-19
    95TYPO

    :conditions => [“username = ‘?’ AND password = ‘?’ ”,

    This line shouldn’t have quotes around the ?s. That results in there being two single quotes before and two single quotes after. It should be as follows.

    :conditions => [“username = ? AND password = ? ”,

    2006-04-12
    93ERROR

    FYI, On Windows in Rails 1.0, digest/md5 is already loaded in the console.

    C:\\>ruby script\\console
    Loading development environment.
    >> require ‘digest/md5’
    => false

    C:\\>irb
    irb(main):001:0> require ‘digest/md5’
    => true

    2006-04-12
    35ERROR

    As i included the generated javascript with ’

    ’ solved the problem.

    2006-04-12
    115OK

    Does not match style of rest of book

    2006-04-12
    45ERROR

    Does not match style of rest of the book

    2006-04-20
    50ERROR

    Since the default name for a HABTM join table would be “carts_products”, that’s what you used as the :join_table in both the ProductReference and Cart model classes.

    However, I don’t see that you created the “carts_products” table. You made a table called ProductReferences, like the model class name.

    I’ve not used HABTM and I didn’t test this code to see if it actually works, but if there’s some behind-the-scenes magic, could you explain it? Or is this a typo? Maybe the table migration (.up and .down) should be changed to “carts_products”? — Wes

    2006-04-19
    106SUGGEST

    In Ch. 24 the book give the following example:

    map.connect ’ :user’ , :controller => ’ recipes’ ,
    :action => ’ list’ ,
    :filter => ’ user’

    The chapter never explains what :filter is all about. It would be helpful if it did.

    2006-04-17
    51SUGGEST

    Recipe 10 Connecting to Multiple Databases.

    By following the code in this recipe (by creating a base class that has the call to establish_connection to the 2nd database) I have successfully connected to MySQL as the primary database and Oracle for the second database. Everytime I do something with a Model that uses Oracle it opens another connection to Oracle. I didn’t think it was suppose to do that.

    2006-04-20
    62TYPO

    After the code excerpt from _content.rhtml, Chad writes, “This is mostly typically display code.”

    I think it’s meant to read, “This is mostly typical display code.”

    2006-04-20
    83TYPO

    Missing space. “Associating a Person with an Address populates both the addressable_idand the addressable_type fields.” Should read, “…populates both the addressable_id [SPACE] and the addressable_type…”

    2006-04-12
    179TYPO

    In the third paragraph, the first sentence starts out as, “Finally, could you install…”. The words “could” and “you” should be reversed so that it reads, “Finally, you could install…”.

    2006-04-12
    71TYPO

    find:
    … will result in your default database’s schema being dump to your console…
    replace with:
    … will result in your default database’s schema being dumped to your console…

    description: “dump” changed to “dumped”

    2006-04-17
    51ERROR

    I have followed the example in the recipe about connecting to multiple databases. My primary database is MySQL, the secondary database is Oracle. The establish_connection call is in a base class just like recipe. The problem is every time I do anything with that model it opens another connection to oracle. It will just keep opening oracle connections forever.

    2006-04-20
    145ERROR

    This handy bit of info at the end of the Continuous Integration recipe is bogus. The migrate runs BEFORE the new migration gets checked out, which is totally useless.

    Assuming you’re using migrations to manage schema changes, you can easily solve this problem by changing the invocation of Rake to look like the following:
    $RAKE -t migrate test_latest_revision NAME=“$APP_NAME” \\
    RECIPIENTS=“$DEVELOPERS” \\
    SENDER=“$BUILDER”

    2006-04-19
    63TYPO

    In the fourth paragraph, second sentence, you have, “Since we already the list() action …”. It should probably be, “Since we already have the list() action …”. The word “have” is missing.

    2006-04-20
    15OK

    In the in_place_select_editor definition at the top of the page, the “if” statement near the bottom is missing its “end”.

    2006-04-12
    133TYPO

    pg133 — “would set it’s first line”

    that’s a possessive its, not an apostrophized it’s (“it has”).

    2006-04-12
    173TYPO

    pg173 — “Application users can then send and receiver simple messages”

    “send and receive”

    2006-04-12
    35SUGGEST

    The text refers to Autocompleter.Local. Perhaps it’s better to give a reference to this rather than requiring users to do a web search on it.

    2006-04-19
    206TYPO

    Don’t be alarmed if this sounds like a for you’d have to
    fill out at tax time.

    9th word should probably be `form’.

    2006-04-12
    164TYPO

    Here’s what our recipes.xml
    template looks like:

    it should be recipes.rxml

    2006-04-12
    99ERROR

    in the code example is says to use layout ‘standard’ (with single quotes) it should be (as far as i can tell) with double quotes (ther are other occurences of this in the sql used in the recepie before this)

    brilliant book!

    2006-04-12
    73ERROR

    “But we still have a problem. Our existing database isn’t ready. In its present form, this migration will wipe out our existing data:”

    Isn’t it the migration files that ‘aren’t ready’, not the database? “Our existing database isn’t ready.”: i found this sentence confusing.

    2006-04-19
    72SUGGEST

    “Here is what the migration file should look like:”

    Perhaps insert a preemptive warning here not to run this migration if you want to avoid data loss.

    2006-04-17
    74SUGGEST

    I’d really appreciate more information about how schema_info relates to migration file numbers because i found the information at the bottom of this page confusing.

    eg. a diagram, or a couple of plain language examples describing what steps ActiveREcord goes through when deciding how to deal with a ‘rake migrate’ command.

    Put another way: why does the migration complain about duplicate tables when schema_info is set to 0, and not when it’s set to 1?

    2006-04-20
    13SUGGEST

    Maybe it would be better to put the code in application.js since that is already created and included in :defaults in Rails 1.1.

    2006-04-19
    14TYPO

    On IE 6, I had to change the code to the following because IE didn’t like a string with opening quote on one line and closing quote on another line.

    Some Value

    2006-04-12
    8TYPO

    Last sentence on page: “May Rails helpers accept…” should be “Many Rails helpers accept…”.

    2006-04-12
    14ERROR

    This doesn’t work on IE 6. The previous fix I submitted removes javascript errors, but when you click on the text the drop down menu doesn’t have any values in it. It works on Firefox though.

    2006-04-20
    18OK

    You are missing the links to the files for example code.

    2006-04-12
    26TYPO

    One extra <% right after initial comment and %> and <% at end of file.

    <%

    <%= grocery_list.person.name %>'s Grocery List</h2> <h3><%= grocery_list.name %>

      <% grocery_list.food_items.each do |food_item| %> <li id="item_<%= food_item.id %>"> \t<%= food_item.quantity %> units of <%= food_item.name %> </li> <% end %> </ul> <% <% <%= sortable_element 'grocery-list', :url => { :action => "sort", :id => grocery_list },
      :complete => visual_effect(:highlight, ‘grocery-list’)
      %>
      <%

    2006-04-19
    32TYPO

    With Rails 1.1 candidate build on Windows XP I get the following error which prevents the example from working.

    NameError (uninitialized constant VERSION):

    It works fine if I replace Rails::VERSION::STRING with “1.1”.

    2006-04-12
    169TYPO

    “rails community” should be “Rails community”

    2006-04-12
    29TYPO

    under “Solution”:
    Just as with Builder … an file name …
    should be ‘a’

    2006-04-12
    77ERROR

    Not sure if this is a true technical error, I will let you decide. In your model definition you use a plural model to describe the relationship of belongs_to (which the rails API defines in the singular)

    http://api.rubyonrails.com/classes/ActiveRecord/Associations/ClassMethods.html

    example:

    belongs_to :firm, :foreign_key => “client_of”
    belongs_to :author, :class_name => “Person”, :foreign_key => “author_id”
    belongs_to :valid_coupon, :class_name => “Coupon”, :foreign_key => “coupon_id”,
    :conditions => ‘discounts > #{payments_count}’

    I followed your example in the book to implement a through relationship in my application but it seems to be broken in rails 1.1

    Hope this helps, :-)

    Best,
    Mark

    2006-04-12
    2TYPO

    Text says “…find the e-mail tab…” but the tab is called “Mail”

    2006-04-12
    171TYPO

    “taken from it’s directory name” — should be “its”

    2006-04-12
    171TYPO

    “extend() is used here instead of include” — should be “include()” (?)

    2006-04-12
    115ERROR

    In the “Stub out Authentication” recipe, the :logged_in? method uses `local_request?` which always returns false for me during functional tests… even on 1.1 revision 4021, with ‘all requests are local’ being true in my ./config/environments/test.rb

    Since all requests are local while in development anyway, it might be a sounder idea to replace `local_request?` with `true` … unless of course you’re going to put your app into production without proper authentication :/

    2006-04-19
    34ERROR

    I’m a newbie so this may be nothing. I tried the Lightning-Fast JavaScript Auto-completion yesterday but it didn’t work. In the controller “book_controller.rb” I had to add on the last line “render(:layout => false)”. Otherwise the included view “authors_for_lookup.rhtml” is rendered as a normal page. Hope I didnt do something stupid.

    2006-04-12
    13TYPO

    Near the end of the page:

    app/vies/contacts/demo.rhtml

    should read

    app/views/contacts/demo.rhtml

    2006-04-12
    163ERROR

    svn externals command for edgerails:

    svn propset svn:externals “rails http://dev.rubyonrails.org/svn/rails/trunk”

    returned this error (on windows XP):

    svn: Explicit target required (‘rails http://dev.rubyonrails.org/svn/rails/trunk’ interpreted as prop value)

    2006-04-12
    163OK

    Include a recipe for creating a new rails project on the edge, not just putting an existing project on the edge.

    (Chad says he won’t have room this time around)

    2006-04-12
    46TYPO

    Second paragraph of Solution, first line config/environtment.rb should be config/environment.rb

    2006-04-20
    1SUGGEST

    Need more details on authentication steps:
    “Our applications’s form consists of a simple eRB view”.
    The reader needs feedback on which folder this should go in, and what to name the file.
    I think I’ve named it right, but it isn’t working.
    If you’d like more information about what I’ve done and the results I’m getting I can send them (i.e. feedback on a the pitfalls a Rails noob may hit here - my email: spit.respectable@gmail.com).

    Also, my rails app also sends email via SMTP. The production.log makes it look like it is successfully sending emails, but I’m not getting the emails. Tips in the email chapter about where to look next to debug this type of problem would be helpful.

    2006-04-12
    77ERROR

    I was implementing a model based on the Many-to-Many where relationship has data in Recipe 16.

    Is the Subscription model correct to have the belong_to naems pluralized? (belongs_to :readers, belongs_to magazines)

    When the belongs_to is pluralized in my code, I get “NameError” errors when trying to call the :through association. Singularizing the belongs_to fixes my problem.

    Another excellent book by the Pragmatic Programmers!

    2006-04-12
    176ERROR

    There’s a `breakpoint` leftover in the `authenticate_access_key` method definition.

    2006-04-12
    35TYPO

    “…the JavaScript library that supports this functional…” should be “…the JavaScript library that supports this functionality…”

    2006-04-12
    86SUGGEST

    In this recipe, on association extensions, I’m missing some details on how to access the different objects if you need to. For e.g. student.grades.my_method(), inside the my_method() definition you’d use self to refer to the grades Array. You might want to mention this. Also, how would you refer to the student object? I’ve solved this by doing self[0].student plus nil handling, but that’s not very elegant.

    2006-04-20
    1SUGGEST

    Recipe idea: validation with Ajax updates. When e.g. using the in_place_editor, or adding items on-the-fly, any validation errors will normally not be displayed to the user. My way of solving this is essentially to return (possibly as JSON) some error data with a 500 error code, so that onfailure is triggered and does something useful with the error data.

    2006-04-12
    57ERROR

    this code:

    def no_more_mr_nice_guy(friend)
    friend.friends.delete(self)
    end

    should be:

    def no_more_mr_nice_guy(friend)
    friend.friends.delete(self) if friend.friends.include?(self)
    end

    or else rails will puke a ‘stack too deep’ error (1.1 edge rev 4125)

    2006-04-20
    206TYPO

    First paragraph in the solution to bounced email:
    “Don’t be alarmed if this sounds like a for you’d have to
    fill out at tax time”
    I suppose you meant ‘form’, not ‘for’

    2006-04-12
    61TYPO

    In the listed ruby code for the tagging section, the following code segment (shows up in two places) has a space in it that prevents the Edit link from working:

    “Element.toggle($(’ #{form_id}’ ))”
    ^

    If you remove the space - the code works correctly. I did a copy/paste from Adobe to the text editor and the space showed up.

    2006-04-20
    9SUGGEST

    I tried putting this in my view but I didn’t get a textarea, ony a regulat text edit field:

    <%= in_place_editor_field :activity, :introduction, in_place_editor_options = {:rows => 8, :cols => 60} %>

    I also tried this an a regular text field to increase the width:

    %= in_place_editor_field :activity, :short_title, in_place_editor_options = {:cols => 60}%

    and also this:

    .inplaceeditor-form input[type=“text”] {
    width: 660px;
    }

    I’m using Rails 1.1

    2006-04-19
    25ERROR

    I am using latest rails/rake and I think the task names and Task class have changed. Here is my clear_database_prerequisites.rake.
    [‘test:units’,‘test:functionals’,‘test:recent’].each do |name|
    Rake::Task[name].prerequisites.clear
    end

    2006-04-19
    165TYPO

    I think it would be a good idea to html escape recipe.author.name in the example xml builder template:

    xml.author h(recipe.author.name)

    2006-04-12
    94ERROR

    The code for authentication is missing from the source code archive available here: http://media.pragprog.com/titles/fr_rr/code/fr_rr-code.tgz

    2006-04-12
    26OK

    the “show @grocery_list” function already exists in the scaffolded controller, and doesn’t need to be typed in

    2006-04-12
    93SUGGEST

    require ‘digest/md5’ will frequently give ‘false’ not ‘true’ (if already loaded). I think this should be explained…

    :)

    2006-04-12
    94TYPO

    Quotes around the ? in the SQL conditions in the signin action will cause it to fail. They should be omitted.

    :)

    2006-04-12
    191TYPO

    “…it just doesn’t looks very…”

    Should be:
    “…it just doesn’t look very…”

    2006-04-12
    119ERROR

    the extract_record task won’t properly escape the data.

    I have a db full of email messages containing all sorts of weird characters (as one might expect). The script will extract fixtures, but the fixtures will not load. could be a bug in to_yaml. still trying to figure out what the inject() call is actually doing.

    in particular, records which contain irb snippets in their bodies cause particular problems.

    2006-04-19
    49TYPO

    The last prose sentence on the page ends with this parenthetical clause: " (the same one the cart table exists ins):" Of course “ins” should be “in”.

    2006-04-20
    119ERROR

    The extract_fixtures task fails to escape erb markup which may be contained in the data.

    for instance a record of an email & body as in my case:

    mail_record.1:
    id: 1
    body: |+
    >>> i like oats. i would use an irb template to say so!
    >>> <“#{oat_liking_status}”>
    >>>
    >>> this is the body of an email,
    >>> so the above shouldn’t
    >>> be interpreted by erb

    unfortunately, erb can only escape_html, which is inappropriate. Should maybe call YAML.escape somewhere?

    2006-04-19
    163TYPO

    “overload plaguing some many of us” should probably read “overload plaguing so many of us”…

    2006-04-17
    1DEFER

    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 and

    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

    \t

    (Chad can’t duplicate the problem)

    2006-05-14
    12TYPO

    Another thing I observed about In-Place form editing - on my machine, if a field never got a value before you started doing in-place form editing on the form, you can’t add a value - I’m not sure if this is another gotcha, or there’s a work around, and something you might want to point out.

    2006-05-14
    251SUGGEST

    The migration at the top of the page doesn’t have the line:

    drop_table in the def self.down method.

    2006-05-14
    127OK

    The Authentication recipe seems a little incomplete. A more complete recipe might be something like putting a login_exception.rb in lib:
    class LoginException < RuntimeError; end

    then raising that in User.authenticate:

    raise LoginException, “Username or password invalid”

    rescuing it in the controller with a flash to capture the exception error message, then redirect back to the signin form:

    def signin
    session[:user] = User.authenticate(params[:username], params[:password]).id
    redirect_to :action => session[:intended_action]
    rescue LoginException => login_error
    flash[:error] = login_error.message
    redirect_to :action => “signin_form”
    end

    and have the signin form display the error:

    <% if flash[:error] then %>

    <%= flash[:error] %>

    <% end %>
    <%= start_form_tag :action => “signin” %>

    (Chad says: I think people can put this together for themselves (as did this reader)

    2006-05-14
    29TYPO

    "We

    2006-07-03
    281DEFER

    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?

    22SUGGEST

    Maybe you should add that the RedCloth library has to be installed for the textilize method to work.

    2006-07-03
    6ERROR

    Unfortunately I’m just having the extract of running rails without databases and the following code

    [:test_units,:test_functional,:recent].each do |name|
    Rake::Task.lookup(name).prerequisites.clear
    end

    don’t seem to be working as Rake API changed somewhat.

    This is what works me instead:

    [“test:units”,“test:functionals”,“test:recent”].each do |name|
    \tRake::Task[name].prerequisites.clear
    end

    2006-05-14
    148OK

    While you’re setting up the search action, you might as well also setup the display action so that your detail views are properly scoped and available in the view template as @detail.

    def self.search_action_for(table, options = {})
    model_class = Object.const_get(Inflector.classify(table))
    display_action = options[:display_action] || “view”
    define_method(:search) do
    search_code = lambda do
    title = options[:title] || "Your #{Inflector.humanize(table)}" search_column = options[:search_column] || 'name' display_as = options[:display_as] || :name
    display_action = display_action results = model_class.find(:all, :conditions =>
    [“#{search_column} like ?”, “#{params[:term]}”])
    render :template => ‘shared/search_results’
    end
    (options[:scoped] false) ? search_code.call : scope(model_class, &search_code) end define_method(display_action) do view_code = lambda do @detail = model_class.find(params[:id]) end (options[:scoped] false) ?
    view_code.call : scope(model_class, &view_code)
    end
    end

    2006-05-14
    230ERROR

    File.open (path, ‘w’) in save_fullsize for image does not work. It have to ‘wb’ to write binary data. otherwise data got courrpted and get error message during rmagic call.

    2006-05-14
    31DEFER

    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.

    32TYPO

    “Potential solutions to this problem using the :update are messy and problematic.”

    probably want to take out the “the” in “the :update”.

    2006-05-14
    149OK

    "Finally, there may be some cases for which we don

    2006-05-14
    160TYPO

    "by ActiveRecord to manage migrations, so we wouldn

    2006-05-14
    161TYPO

    “To extract the fixtures from your production database, you would run set the RAILS_ENV environment variable to ”production“.”

    “Run” seems left over from an earlier version of the same sentence which probably said something like “run in production”.

    2006-05-14
    141OK

    I suggest some differentiation between the new and edit functions simply because the edit template will differ. By trying to use the edit template for everything, you may introduce a fair amount of unnecessary conditional logic into that template. E.g.:

    def edit
    catalog = Catalog.find_by_id(params[:id]) || Catalog.new if request.post? catalog.attributes = params[:catalog]
    redirect_to :action => ‘list’ and return if catalog.save else render(:action => 'new') and return if catalog.new_record?
    end
    end

    Note that I’ve used Catalog instead of the original Recipe. That’s because I’m using this in my app — you’d have to change the object back to Recipe to correspond to the original.

    2006-05-14
    49TYPO

    missing parenthesis.

    “If you turn your head to the side and squint at this code, you can see that, in the loop, it defines a method with the same name as each helper (such as text_field() and text_area() which sets up a table row,”

    should probably be

    “(such as text_field() and text_area())”

    2006-05-14
    51TYPO

    “Discussion: Anything special to say about this one?”

    Realistically you guys probably already have seen this, since it’s obviously placeholder text, but fwiw, this would be a great place to put pointers to info re: metaprogramming in Ruby, or perhaps just why metaprogramming can be so readable.

    2006-05-14
    116TYPO

    Shouldn’t
    :mapping => [%w(modelattrname specialclassattr)]
    be
    :mapping => [%w(model_attr_name special_class_attr)]
    instead ?

    2006-05-14
    194SUGGEST

    I believe you’d want something like this to prevent duplicate Musicians at each run of the rake task.

    Musician.create(data) unless Musician.find_by_given_name_and_surname(data[“given_name”], data[“surname”])

    2006-07-06
    15DEFER

    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

    128OK

    After following the code examples and trying to use script/console to run the example User.create and subsequent User.password, Rails seems to not think that the password method exists. Aside from the changes below in the model (I use first_name, last_name, and email_address instead of just username) I have followed the book verbtim, even going so far as to recreate the rails project from scratch.

    lusciouscreamy:~/Sites/usermanager nick$ ruby script/console
    Loading development environment.
    >> nick = User.create(:email_address => “nick@generalthings.com”, :first_name => “Nick”, :last_name => “Hodulik”)
    => #<User:0x244d634 errors=#<ActiveRecord::Errors:0x2449250 errors={}, base=#<User:0x244d634 ...>>, attributes={“password_salt”=>nil, “id”=>5, “password_hash”=>nil, “first_name”=>“Nick”, “last_name”=>“Hodulik”, “email_address”=>“nick@generalthings.com”}, @new_record=false>
    >> nick.password = “test”
    NoMethodError: undefined method `password=’ for #
    from /opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1789:in `method_missing’
    from (irb):2

    (Chad could not reproduce this)

    2006-07-06
    124ERROR

    It would be nice if you added ‘require “digest/sha2”’ to the User class. That way people won’t have to look up the proper require statement.

    2006-07-06
    62OK

    This:

    Note that we

    2006-07-03
    59TYPO

    2 errata, same page, one submission.

    Remove “by” from this sentence, below the listing for models/product.rb

    As we learned earlier, by Active Record establishes connections in a
    hierarchical fashion.

    In the following sentence, change “looks” to “look”:

    When attempting to make a database connection, Active Record models looks for the connection associated with either themselves or the nearest superclass.

    2006-07-03
    234ERROR

    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

    84ERROR

    The footnote (11) for the rake task db:schema:dump says ‘Or db:schema:dump if you’re using Rails 1.0’ - it should say ‘db_schema_dump’.

    2006-07-03
    118OK

    Since you’re storing the user’s ID, not a User object, it might be clearer to rename session[:user] to session[:user_id]

    2006-07-03
    117TYPO

    Linked file admin_controller.rb seems to be missing the line:
    session[:intended_controller] = controller_name

    2006-07-03
    53ERROR

    The recipe doesn’t work with an app generated with Rails 1.1 (which include integration tests - they fail in that case).

    The fix should be to add :test_integration to the list of prerequisites to be cleared:

    [:test_units, :test_functional, :test_integration, :recent].each do |name|
    Rake::Task[name].prerequisites.clear
    end

    2006-07-06
    72OK

    For Rails 1.1 I get “undefined method `parse’ for Tag:Class” and needed to delete models/tag.rb in order to fix it, solution was taken from http://noobonrails.blogspot.com/

    (Chad says: this problem was because the user already had a model named Tag, so the class names conflicted)

    2006-07-06
    134TYPO

    http://locahost:3000/uta/tumba/chennaagide is missing an l in (should be localhost and not locahost)

    2006-07-03
    264DEFER

    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.

    254ERROR

    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.

    57TYPO

    So, in the default case, all your models get access to this default con- nection. But, ActiveRecord::Base. If you make a connection from one of your model classes (by calling establish_connection( )) >>> In the first full paragraph you have “But, ActiveRecord::Base.” I assume that part of a sentence is missing here. Given the importance of this to some people, please provide the rest of the sentence. Thanks!

    2006-07-03
    119TYPO

    The line if request.post? is missing from the final code listing

    2006-07-03
    27OK

    I had to change the call to start_form_tag to get the code to work.
    Changed

    from <%= start_form_tag({:action => “save”}, :id => “entry-form”)

    to: <%= start_form_tag({:action => ‘save’}, {:id => ‘entry-form’}) %>

    I’m using rails REVISION_4365

    (Cahd could not reproduce this)

    2006-07-06
    126SUGGEST

    At the end of first page of “Recipe 31: Authenticating Your Users”, it shows the generation of a migration to create the user table. On the next page, it shows generating a model for User after “rake migrate” is called. This order of steps doesn’t work well with the current version of Rails (1.1.x). When you generate the model for User a migration is automatically generated. If you wish to adhere to the current Rails generation mechanism, one should generate the model, update the create migration and then run “rake migrate” to create the table. The procedure in the book leaves an extraneous migration file that should be deleted.

    2006-07-06
    134OK

    Please include a description of the “signin_form”. What is “signin_form”? It shows up twice in code examples, but no where is the member function or rhtml shown. How does it differ from “signin”, which is shown in an earlier recipe?

    (Chad feels that the concept is probably widely ubnderstood, and would rather not add more content to this recipe)

    2006-07-06
    8TYPO

    capitalize IRC

    2006-07-03
    146TYPO

    created_at is listed twice instead of using updated_at

    2006-07-03
    147TYPO

    created_at is duplicated

    2006-07-03
    168TYPO

    so is it ERb or eRB?

    2006-07-03
    256TYPO

    URL runs off page

    2006-07-03
    84TYPO

    “Of Rails 1.0” should read “As of Rails 1.0”

    2006-07-03
    123OK

    “def self.up” is indented on space too many

    2006-07-06
    116TYPO

    When doing “ruby script/generate model User” it creates another migration even though we previously built one by hand.

    2006-07-06
    75TYPO

    There seems to be an extra

    on the bottom of the _content partial.

    2006-07-03
    28TYPO

    it’s “the_list” in the book but the download link to change.rjs contains “the-list”

    2006-07-03
    29OK

    mixes hyphens with underscores

    2006-07-03
    122TYPO

    The automatically created migrations are XXX_create_roles.rb and XXX_create_rights.rb not XXX_add_

    2006-07-03
    31OK

    "… if you are using layouts, you

    2006-07-06
    22OK

    "you can

    2006-07-03
    37TYPO

    Closing span tag has extra indentation.

    2006-07-03
    44TYPO

    Between ‘class’ and right before the class’ ending ‘end’ the indentation is one more than it should be.

    2006-07-03
    46TYPO

    The “class” line appears to be cut off

    2006-07-03
    284ERROR

    In the code, node.to_s.gsub(/</, “&LT;”) is trying to replace the less-than with the HTML code for less-than. The expression in the book is double encoded, which would cause the user to see “<” instead of “<”. The replacement should be “<”.

    2006-07-06
    42ERROR

    The line:
    <% form_for :contact, :builder => TabularFormBuilder do |f| %>

    consistently gives me the error:
    uninitialized constant TabularFormBuilder

    However it works if I use:
    <% form_for :contact, :builder => ApplicationHelper::TabularFormBuilder do |f| %>

    2006-07-06
    4OK

    Some of the <%= are written as <%- and the code doesn’t work.

    (Chad says: I can’t find any of these)

    2006-07-03
    6DEFER

    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.

    80ERROR

    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 :-).

    338TYPO

    The price listed for the discounted PDF is wrong. It is shown as $5.00, and it should be $7.50

    2006-07-03
    53ERROR

    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

    134ERROR

    Your date route is spot-on, except for: “Defaulting to the current day”

    283TYPO

    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.

    130ERROR

    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.

    32ERROR

    “we put relative path to our JavaScript
    action” — it’s an absolute path, no?

    57TYPO

    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.

    61TYPO

    In the second sentence of the second paragraph, “You’d” should not be capitalized.

    112SUGGEST

    Don’t forget to save the changes to the database:
    >> address.save

    119TYPO

    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”

    139ERROR

    “if request.post?” is missing in the signin action of the full AdminController code listing (the last code piece on the page).

    276TYPO

    Appendix A - ‘tis’ should be ‘this’

    140ERROR

    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

    155TYPO

    Mild grammatical : “We have multiple ways to achieve this affect, …”

    should that be “effect” ?

    296ERROR

    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.

    173ERROR

    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.

    75TYPO

    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.)

    151ERROR

    Render CSV

    Example code gives error: NameError in ExportController#orders

    Need to add require “CSV”

    86TYPO

    4th paragraph: "

    101SUGGEST

    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.

    197SUGGEST

    It would seem to me that Recipe 49: “Dealing with Time Zones” ignores daylight saving time.
    To have that included would be immensely helpful!

    13SUGGEST

    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(/\
    /, “”))}’) if options[:select_options]

    function << (‘, ’ + options_for_javascript(js_options)) unless js_options.empty?
    function << ‘)’
    javascript_tag(function)
    end

    71ERROR

    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)

    287321TYPO

    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…

    272SUGGEST

    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.

    199SUGGEST

    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.

    198ERROR

    The headers instance variable is deprecated in Rails 1.2. Instead, simply remove the "" symbol so that the headers setter method is called.

    149TYPO

    In the description of the solution, you say that you will use an “after_filter”, but then you actually implement a before_filter.

    149ERROR

    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

    146SUGGEST

    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.

    46ERROR

    I tried the code, and the class CodeStatistics was not known. So I had to include require ‘code_statistics’ to get it to work.

    219ERROR

    Image#save_fullsize should be using write, not puts to write out the binary data.

    228TYPO

    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.

    1SUGGEST

    It would be easier to find the samples in the download if they were ordered by Chapter Number. (JMHO)

    142ERROR

    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.

    78ERROR

    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

    150ERROR

    session_expiry() doesn’t invoke the RJS template, this is the error it produces:

    You called render with invalid options : /application/redirect

    87TYPO

    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!

    136ERROR

    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)

    55ZtdazERROR

    good guest page.
    thank you.

    243ERROR

    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.

    13ERROR

    Scriptaculous in_place_editor does not work with Rails 2.1 as described in the book.

    45ERROR

    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

    Categories: