Adding class to select options

I have…

<%= select(:machine, :name, Machine.find(:all).map {|m| [,]},
{}, :class => “something” %>

This gives me…

AZ01 AZ02 AZ03

What I am looking for is…

AZ01 AZ02 AZ03

How do you do this?



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

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