Select(object, method, choices, options = {}, html_options =

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:


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

<%= select(‘night’, ‘place_id’ , Place.find_all.collect {|p| [ p.name,
p.id ] },{:selected => @night.place_id}) %>
casting the value of place_id
:selected => @night.place_id.to_i
I get what I want. I’m not sure about the reason of this, maybe cause
I’m using two models.


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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs