[Rails] select(object, method, choices, options = {}, html_options = {})

Enrico Teotti
Tue, 04 Jul 2006 09:33:17 -0000

Hi,
I''m using:
select(object, method, choices, options = {}, html_options = {})
I''ve read the API where there''s this example:
select("post", "person_id", Person.find_all.collect {|p| [
p.name,
p.id ] }, { :include_blank => true })
should give this code:


    <option value="1"
selected="selected">David
Sam
Tobias


The API says:
"By default, post.person_id is the selected option. Specify :selected
=> value to use a different selection or :selected => nil to leave all
options unselected."
But this is not working to me. Is it for anybody?
First I think post.person_id is @post.person_id. Anyway it doesn''t put
the selected property. Even forcing a :selected => value this way:
<%= select(''night'', ''place_id'' ,
Place.find_all.collect {|p| [ p.name,
p.id ] },{:selected => @night.place_id}) %>
doesn''t work.

Thanks,
Enrico

--
"The only thing necessary for the triumph of evil
is for good men to do nothing"
 Edmund Burke