struggling with formhelper select tag

Hi -

There are two basic cases where I want to use FormHelper (form_for) to
create select tags:

1) Where the options come from another table
2) Where the options come from a manually created list or hash

An example of 1 might be a tagging application. I may have a photo
sharing site that lets users select a tag from a list box (select) and
the tags come from a table.

An example of 2 might be a new/edit user form where gender is male or
female and male is stored as 1 and female is stored in 2.

I cannot find a simple example of these 2 cases. So,

a) can someone post a simple example of both
b) where does a new rails developer find docs for this stuff?


ok, this one does both at once:

<% form_tag(invitations_path(), :method => :get) do %>
  <%= label(:registration_group, 'Group') %>
  <%= select(:registration_group, :id, [["all", 0]] +
(@registration_groups.collect{|rg| [,]}),
              {:selected => 0)}, {:onchange => "this.form.submit();"})
<% end %>

the idea is to select a group for invitations to be shown
together with an "all" entry

the basic thing is to hand over an array with the key/value pairs
you can use a simple array as the all entry [["all", 0], ["more", 1]]
or collect an db-record into such an array
and as here, combine several arrays as long as the ids don't conflict

selected is always zero here, you could give it any key
onchange triggers the form submit, you could use a 'normal' submit

you'll find this documented here:

the usage of select:

you'll find this documented here:

the usage of select:

Posted via

Thanks so much. This was a vocabulary problem. I was looking under
FormHelper and saw no select tag. I didn't realize there was a

Thanks again,