options_from_collection_for_select

Daniel Waite wrote:

options_from_collection_for_select([ nil, nil ] + @airlines, 'id', 'name')

This won't work. I don't always want to use collection_select since I don't always need the object/model bindings (i.e. in a search form). So this worked for me:

<%= select_tag "some_select", "<option></option>" + options_from_collection_for_select(@foo, "id", "item") %>

This works because options_from... returns a string of <option> tags. Just add a blank option tag on to the front of the string.

Cheers, David