views:

23

answers:

1

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", "test"}, :class => "selected", :class => "selected") %>
A: 

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!

j.