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("<optgroup label='Active Users'><option> " + data.collect {|a| [ a.name, a.id ] } + " </option></optgroup>")],
                    {:include_blank => ' '}, class: 'closed_filters', filter: available_filter_option.col_names, :filter_type => 'select_box'

Thank you in advance guys.

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("<optgroup label='Active Users'><option> " + data.collect {|a| [ a.name, a.id ] } + " </option></optgroup>")],

{: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: grouped_collection_select (ActionView::Helpers::FormOptionsHelper) - APIdock

Walter