I have…
<%= select(:machine, :name, Machine.find(:all).map {|m| [m.name, m.id]},
{}, :class => “something” %>
This gives me…
AZ01 AZ02 AZ03What I am looking for is…
AZ01 AZ02 AZ03How do you do this?
Thanks,
~Jeremy
I have…
<%= select(:machine, :name, Machine.find(:all).map {|m| [m.name, m.id]},
{}, :class => “something” %>
This gives me…
AZ01 AZ02 AZ03What I am looking for is…
AZ01 AZ02 AZ03How do you do this?
Thanks,
~Jeremy
You can swap the order of the name and id fields in the array to get the
right values and inner content in the option elements, but I don’t think
there’s a convenient way to specify the CSS class of the option
elements.
You can either build the elements yourself (maybe with content_tag) or
add them using Javascript. It should be pretty easy to do with the
Prototype library (which is included in Rails by default). Try using
$$(‘select.something’) to get the select element with the class
“something”, then addClassName(“something”) on each option child
element.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs