What if I need to add a class to the options tag?
<option value="testme1" class="selected">testme1</option>
I haven't been able to do this.
This is what I have
<%= select(:user, :goalstext, Bodytarget.all.collect {|b| [ b.name, b.id ] },{"class"开发者_如何学JAVA, "test"}, :class => "selected", :class => "selected") %>
Try this:
<%= select(:user, :goalstext, Bodytarget.all.collect {|b| [ b.name, b.id ] },
{}, {:class => "selected"}) %>
Remember the params' order:
select(object, method, choices, options = {}, html_options = {})
EDIT
I'm sorry, I read your question too fast. My code will add class to the select, not the options. I'll check how to do what you want... sorry!
精彩评论