collection_select

These tags are always tricky, so here's some good syntax hints!

The 5 values are…

<%= collection_select 
  :user,      This is the base table that the form is for
  :GRP_ID,    This is the field in the base table that has the foreign key.
  @groups,    This is the collection, frequently the lookup table you are referencing (populated in the controller).
  :id,        This is the key field in that other, foreign, reference table, usually id
  :name %>    This is the reference table field (usually text) for the drop-down list options that users actually see in the browser.

To set the prompt and the class:
<%= collection_select :assign, :manager_id, @managers, :id, :manager_name, 
  options ={:prompt => "Select a manager"},
  html_options ={:class =>"listBox"} %>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s