Search code examples
ruby-on-rails-3formshelper

Rails 3 - select_tag helper - Blank option tag


I have a select_tag populated from a @users array that I'm using to perform searches. When the user first lands on the page, I'd like it to display a blank or custom tag, rather than the first item in the array?

Is this an option using the select_tag helper? To insert a blank "" option?

My helper so far:

<%= select_tag :search_user, options_from_collection_for_select(@users, "id", "name"), :class => 'submittable'%> 

Solution

  • You can use the option :include_blank => true as documented here.