Accessing associations in a form helper

I’ve got two models, a Company and a User, and a Company belongs_to a
User. When I create/edit a company object, I’d like to be able to
modify the associated user. Can I do this directly with form helpers?
Something like
text_field(“company.user”, “login”)

Right now I’m having a user object and a company object, and then
associating them with @company.user = @user in my controller. Just
wondering if I can use the association directly, or if there’s some
preferred way to do this.

Pat

On 1/16/06, Pat M. [email protected] wrote:

Because the helpers rely on specifically-named instance variables, you
end up having to do this:
<% @user = @company.user -%>
<%= text_field ‘user’, ‘login’ %>

Unfortunate, but there’s no way to ask an object what name it was
bound to in the calling context, so Rails has to ‘cheat’.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs