Search code examples
ruby-on-railsselecthaml

Adding a default null value to a select tag


I currently have this line of code:

=select_tag :resource_id, options_for_select( Resource.find(:all, :conditions => "resourcetype = 'data-sheets' && category = 'Data Centres'", :order => "title ASC").map{|l| [l.title, l.id] }, @dc.try(:resource_id) )

Which works in the sense it displays a list pulled from the database, and selects the current value of the field, but I need to add a "please select" option to the top of the list with no value..


Solution

  • There's an option for "blank"

    :include_blank => true
    

    Additionally you can use prompt to set the value of that text