You can create a helper like this one using options_for_select
def my_select(object, method, choices, options = {})
html = ""
if options[:id]
html << "<select name=''#{object}[#{method}]''
id=''#{options[:id]}''>"
else
html << "<select name=''#{object}[#{method}]''
id=''#{object}_#{method}''>"
end
html << options_for_select(choices, options[:selected])
html << "</select>"
html
end
And call it from the view
<%= my_select ''telephone'', ''type'',
@telephone_types, :selected =>
''Mobile'' %>
Or if you want a blank option at the top (or display any text) you can
use the :prompt option.
<%= select(''telephone'', ''type'',
@telephone_types, {:prompt => "Select
Type"}) %>
Hope this helps
Rafa
--
Posted via http://www.ruby-forum.com/.