There are many posts about this... and I'm pretty sure my syntax is right, but for some reason
:select => "some value or text" is not working for me.
here is my form:
=form_for(@pet) do |f|
=f.label :name
=f.text_field :name, :placeholder => 'enter pet name...'
%p
=f.label :species
=f.text_field :species, :placeholder => 'enter species name...'
%p
=f.label :color
=f.text_field :color, :placeholder => 'enter color of pet...'
%p
=f.label :pet_store_id
= f.collection_select(:pet_store_id, PetStore.all, :id, :name, {:selected => "Moe's Mammals"})
= f.select(:pet_store_id, PetStore.all.map {|p| [p.name,p.id]}, :selected => "Moe's Mammals")
%p
=f.submit
See the last one...it will list all my PetStore names, which is what I want, but it always defaults to the first name in that list.... even though "Moe's Mammals" is the exact name of another pet store that is on the drop down list.
the second f.select is just the same thing in a different syntax... but it also doesn't work. Even though :prompt => "whatever" will work fine. It leads me to believe that :selected doesn't mean anything to ruby