I’m finally a happy developer of a Rails app that’s got a working drop-
down. In short, I prefixed the array of Vendors (which all have
integer IDs > 0) with an new Vendor with in ID of 0 and a string
“Select …” in the field that populates the drop down. I’ll use some
kind of “before” command to report “selection req’d” if no valid
selection had been made upon creating/saving/whatever.
The code below works. Is there a better “Rails way”?
Thanks in Advance,
<%= f.label :vendor %><br /> <% @vendors = Vendor.find( :all, :order=>"nickname ASC") -%> <% @v = Vendor.new; @v.id=0; @v.nickname = "--Select Vendor--" -%> <% @vendors.insert(0, @v) -%> <%= f.collection_select(:vendor_id, @vendors, :id, :nickname) %>