Ruby Rails collection select is displaying blank "prompt" value?

Tony picture Tony · Apr 17, 2009 · Viewed 20.3k times · Source

I have a collection select like the following:

<%= f.collection_select :region_id, Region.find(:all), :id, :name, { :prompt => 'Select a State/Province' }, :style => "width: 200px;" %>

Sometimes the prompt from the :prompt option appears, but sometimes it does not. Does anyone know where I could begin to troubleshoot this? Maybe I have been looking at it too long...

Answer

Graeme picture Graeme · May 14, 2009

:include_blank with the value of your blank option seems to do the trick. Try this:

 {:include_blank => "Please select"}