Hi,
I’m trying to generate a select with this :
select(“music”, “music_location_id”, MusicLocation.find(:all, :order =>
“name ASC”).collect {|p| [ p.name, p.id ] }, { :include_blank => true })
I need to add a description because the name is very “cryptic” and I’d
like to do something like :
p.name (p.description)
I don’t know how I can do it with HTML option field. The api is not
telling much about it.
Thanks
On Aug 6, 9:51 am, David N. [email protected]
wrote:
Hi,
I’m trying to generate a select with this :
select(“music”, “music_location_id”, MusicLocation.find(:all, :order =>
“name ASC”).collect {|p| [ p.name, p.id ] }, { :include_blank => true })
Rails just sticks the first part of each of those arrays in the option
description. If p.name isn’t what you want, then just put something
else there.
Fred
Frederick C. wrote:
On Aug 6, 9:51�am, David N. [email protected]
wrote:
Hi,
I’m trying to generate a select with this :
select(“music”, “music_location_id”, MusicLocation.find(:all, :order =>
“name ASC”).collect {|p| [ p.name, p.id ] }, { :include_blank => true })
Rails just sticks the first part of each of those arrays in the option
description. If p.name isn’t what you want, then just put something
else there.
Fred
The thing is that sometime, description is empty so I can’t just put
p.description
but I would like p.name (p.description)
I guess there’s something I can put in the HTML option hash but it’s not
described in the API apart for :include_blank
Maybe there’s something like :option_key => “#{p.name}
(#{p.description})”,
do someone knows about it?
David
On Aug 6, 10:02 am, David N. [email protected]
wrote:
Rails just sticks the first part of each of those arrays in the option
description. If p.name isn’t what you want, then just put something
else there.
Fred
The thing is that sometime, description is empty so I can’t just put
p.description
but I would like p.name (p.description)
I don’t think you understood me - you can put any bit of ruby you want
there, as long as it evaluates to a string (or something that looks
like it).
For example “#{p.name} - #{p.description}”
Fred