Populating Select Box with Hash Array

Hi, stuck with another little problem, select lists / drop down boxes.
Tried to avoid these because the code looks uber scary.

Anyway I’ve created a Hash Array called gender:

@gender = [‘Man’ => ‘male’, ‘Woman’ => ‘female’]

here you’ve got the key (being the english name) and the value (the
generic equivalent).

what I want to do is make a drop-down single-selection box use these
key/value properties to render it correctly,

<%= select(“search”, “type”, @gender) %>

…this doesn’t work but what i’d like is generate the form code…

Man Woman

I’d then read the value off the form via:

@selection = params[:search]

Where am I going wrong?, I know i need some kind of {key, value} clause
in the select() control but unsure where.

Any help really appreciated,

Sincerely

John.

Thorsten M. wrote:

maybe options_for_select would do the trick?
ActionView::Helpers::FormOptionsHelper

may well, thanks for that Thornsten :wink:

will try that tonight and see how it goes (god i love you people!)

maybe options_for_select would do the trick?