Select dropdown for belongs_to field

Hi,
I have a ‘person’ model that belongs_to a ‘group’ model. I used
scaffolding to generate the form code for adding a new person, but I
want a select drop-down for selecting which group to assign a person
to. I looked at the rails form helpers guide, and tried a few
different things in the template, like:

<%= f.select :vendor, @vendor %>
but i’m getting errors…

what’s the proper way to do this? is there any controller code
necessary?

thanks!

skunkwerk wrote:

Hi,
I have a ‘person’ model that belongs_to a ‘group’ model. I used
scaffolding to generate the form code for adding a new person, but I
want a select drop-down for selecting which group to assign a person
to. I looked at the rails form helpers guide, and tried a few
different things in the template, like:

<%= f.select :vendor, @vendor %>
but i’m getting errors…

what’s the proper way to do this? is there any controller code
necessary?

thanks!

here is it is
f.select(:group_id,Group.all,:prompt => true)
i think it should work

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