How to make optgroup with rails version 3

I am trying to set up a drop down list with a optgroup with active
users. i
know the following code is wrong, but would there be any way of doing
this
how i have it? right now if you take the raw section and just have
data.collect {|a| [ a.name, a.id ] } instead, it works great for just
showing the names of the users, but i want to add that optgorup. How
would
i go about doing that?

= f.select “#{available_filter_option.col_names}”, [raw(" " + data.collect {|a| [ a.name, a.id ] } +
" ")],
{:include_blank => ’ '}, class: ‘closed_filters’,
filter: available_filter_option.col_names, :filter_type => ‘select_box’

Thank you in advance guys.

On Apr 24, 2014, at 4:18 PM, Bernardo Carrasco wrote:

I am trying to set up a drop down list with a optgroup with active users. i know
the following code is wrong, but would there be any way of doing this how i have
it? right now if you take the raw section and just have data.collect {|a| [
a.name, a.id ] } instead, it works great for just showing the names of the users,
but i want to add that optgorup. How would i go about doing that?

= f.select “#{available_filter_option.col_names}”, [raw(" " + data.collect {|a| [ a.name, a.id ] } + "

")], > > > {:include_blank => ' '}, class: 'closed_filters', filter: available_filter_option.col_names, :filter_type => 'select_box' > Thank you in advance guys. > >

I’m assuming you tried the grouped_collection_select helper for creating
a picker with opt groups, and found that you could not control the order
of the opt groups in the list, right? I just hit this a few months ago,
and couldn’t find any way out of it except hand-coding the outer select
and letting the options_for_select picker build the inner parts.
Otherwise, the opt groups came out in alphabetical order, and nothing
could change that.

If you haven’t tried that yet, then start here for some docs:
http://apidock.com/rails/ActionView/Helpers/FormOptionsHelper/grouped_collection_select

Walter

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs