Inserting a nil value into a Select/Drop Down Menu

Since options_from_collection_for_select returns a string of normal <option> tags, you should be able to just append it to your own <option> tag:

<%= select_tag "cuisine_id", "<option value=''>All Cuisines</option>" + options_from_collection_for_select(@cuisines, 'id', 'name') %>

Or make a helper that does this for you.

Justin

Rich,

Does this code still work if you have a form validation error? Where are you declaring the @cuisines object?

The option way works, but I do it this way as well for a list of countries where I want USA to appear first…

@usa = Country.find(:first, :conditions => [“name = ?”, usa_name]) @countries = Country.find (:all, :conditions => [‘country_code IS NOT NULL AND name <> ?’, usa_name], :order => ‘name ASC’) @countries.insert(0, @usa)

You might want to do a similar thing in your controller, who knows.