I am currently reading the Rails Recipes book and like the chapter on
providing your own in_place_editor for enumerations / selects.
I understood so far, or I believe that I understood ;-), how to do
for a field that uses values only, like choosing from “red”, “black”,
“green”. What I fail to understand is how to chose from associated
Consider the following example. A “Reader” has_one “Book”, the book
is currently reading. Both “Reader” and “Book” are model objects. How
you go about at view to make the current book selectable?
is trivial to make the IDs (book_id) selectable, but I would rather like
user to select from a list of book titles than from a list of book ids.
If I provide the in_place_editor with the ids and titles of the
book as select options it works on the surface (book titles can be
ids are used for the update calls), but the current value displayed in
tag is still an id. And I believe that I have to provide the
helper method with “:reader” and “:book_id”, because it uses it for the
Providing a new parameter to the helper method for creating the
in_place_editor might work, but it seems that there is some stuff
under the hood retrieving the original id when creating the instance
Would it be an option to overwrite the result? If so how to find which
attribute? tag.inspect returns pages of variables. What to look for?
Btw. What is the easiest way to open a referenced class, like
from within TextMate, when you don’t know what the source file is a
Is a global search in the project the only option?
I am at loss here what to do without rewriting most of the existing
relevant to in_place_editors?
On the other hand though handling of associations in the view is also
absent in the generated scaffolds and I haven’t seen any support for
any other view related topic. Am I doing something wrong and don’t
understand the Golden Path™? Isn’t choosing from associated objects
every day case?
Any help and insight is appreciated.