# How to change the order of the group\_method parameter in the grouped\_collection\_select method?

**URL:** <https://www.ruby-forum.com/t/how-to-change-the-order-of-the-group-method-parameter-in-the-grouped-collection-select-method/195507>\
**Category:** Rails\
**Created:** [September 24, 2010, 2:08am UTC](https://www.ruby-forum.com/t/how-to-change-the-order-of-the-group-method-parameter-in-the-grouped-collection-select-method/195507 "2010-09-24T02:08:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Demetrius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f08c70/32.png) [@Demetrius](https://www.ruby-forum.com/u/Demetrius)\
**Post date:** [September 24, 2010, 2:08am UTC](https://www.ruby-forum.com/t/how-to-change-the-order-of-the-group-method-parameter-in-the-grouped-collection-select-method/195507/1 "2010-09-24T02:08:42Z")

</div>

Anyone know how to order the group\_method parameter in the  
grouped\_collection\_select method? I get a nice list of subjects in my  
drop down BUT they are not in order (alpha…)

My code is below (:subjects is my group\_method parameter).

```
<%= grouped_collection_select(:course, :subject_id,

```

State.where(“id = ? OR state\_abbr = ?”, current\_teacher.state\_id,  
‘CC’), :subjects, :name, :id, :name, {:prompt =\> true} )%\>

I’ve tried something like this: Subject.order(‘name’)… but get the  
following error:

(eval):1: syntax error, unexpected $end  
group.#ActiveRecord::Relation:0x00000102cb71d8

Or, :subject.order(‘name’)… but get this error:

undefined method `order’ for :Subject:Symbol

---

<div class="post-metadata">

**Author:** ![Demetrius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f08c70/32.png) [@Demetrius](https://www.ruby-forum.com/u/Demetrius)\
**Post date:** [September 24, 2010, 7:03pm UTC](https://www.ruby-forum.com/t/how-to-change-the-order-of-the-group-method-parameter-in-the-grouped-collection-select-method/195507/2 "2010-09-24T19:03:41Z")

</div>

Oops, rere are the associations:

State  
has\_many :subjects

Subject  
belongs\_to :state  
has\_many :courses

Course  
belongs\_to :subject
