On Oct 9, 2006, at 5:24 AM, [email protected] wrote:
Actually, I want to display other fields in the moderators table, and
traverse the association, like this:
<%= text_field “group.moderator”, “login” %> or <%= text_field
“group”, “moderator.login” %>
where “login” is an atttribute of the “moderator” which is associated
with the “group”.
Neither of these approaches works, but “@group.moderator.login” is a
Helpers like text_field have this signature
text_field(object, method, …)
where “object” is the name of an instance variable in the view
(idiomatically a symbol), and “method” the name of an accessor.
Behind the scenes, the helper gets the variable dynamically and sends
() method to it. With that call the helper sets the initial value of
the widget, and constructs the name “object[method]”. That’s very
handy, because most of the time is just what you need.
You need to switch to the generic *_tag family of helpers for extra
flexibility, in this case text_field_tag.