# Why isn't :order working in acts\_as\_list

**URL:** <https://www.ruby-forum.com/t/why-isnt-order-working-in-acts-as-list/68179>\
**Category:** Rails\
**Created:** [September 10, 2006, 2:07am UTC](https://www.ruby-forum.com/t/why-isnt-order-working-in-acts-as-list/68179 "2006-09-10T02:07:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cc9497/32.png) [@jack](https://www.ruby-forum.com/u/jack)\
**Post date:** [September 10, 2006, 2:07am UTC](https://www.ruby-forum.com/t/why-isnt-order-working-in-acts-as-list/68179/1 "2006-09-10T02:07:03Z")

</div>

Ok, I’m sure this has to be something stupid that I’m doing (or not  
doing), but I can’t seem to get things to order by the specified column.

class List \< ActiveRecord::Base  
has\_many :list\_items, :order =\> “orderby”

The error I get back when trying to save the link is:

Unknown column ‘position’ in ‘order clause’: SELECT \* FROM list\_items  
WHERE (list\_id = 9) ORDER BY position DESC LIMIT 1

So it looks like its just defaulting to ‘position’, and isn’t getting my  
value of orderby. Is there something obvious i’m missing here? This is  
getting annoying…

Any help or thoughts would be great. Thanks!

Jack

---

<div class="post-metadata">

**Author:** ![jack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cc9497/32.png) [@jack](https://www.ruby-forum.com/u/jack)\
**Post date:** [September 10, 2006, 2:35am UTC](https://www.ruby-forum.com/t/why-isnt-order-working-in-acts-as-list/68179/2 "2006-09-10T02:35:52Z")

</div>

On 9/9/06, jack [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Unknown column ‘position’ in ‘order clause’: SELECT \* FROM list\_items  
> WHERE (list\_id = 9) ORDER BY position DESC LIMIT 1
> 
> So it looks like its just defaulting to ‘position’, and isn’t getting my  
> value of orderby. Is there something obvious i’m missing here? This is  
> getting annoying…
> 
> Any help or thoughts would be great. Thanks!

I think ‘acts\_as\_list’ assumes you have a “position” column in your  
table (that it manages), and ordering is always by that column, no?

---

<div class="post-metadata">

**Author:** ![jack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cc9497/32.png) [@jack](https://www.ruby-forum.com/u/jack)\
**Post date:** [September 10, 2006, 3:15am UTC](https://www.ruby-forum.com/t/why-isnt-order-working-in-acts-as-list/68179/3 "2006-09-10T03:15:28Z")

</div>

Michael C. wrote:

> On 9/9/06, jack [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Unknown column ‘position’ in ‘order clause’: SELECT \* FROM list\_items  
> > WHERE (list\_id = 9) ORDER BY position DESC LIMIT 1
> > 
> > So it looks like its just defaulting to ‘position’, and isn’t getting my  
> > value of orderby. Is there something obvious i’m missing here? This is  
> > getting annoying…
> > 
> > Any help or thoughts would be great. Thanks!
> 
> I think ‘acts\_as\_list’ assumes you have a “position” column in your  
> table (that it manages), and ordering is always by that column, no?

Hmm…at first I thought you were mistaken, but now that I think about  
it, maybe I’m just getting this wrong? hmm…i’ll have to look around  
more…it does seem that forcing a programmer to use a column only named  
position without being able to override it would be less than optimal…

---

<div class="post-metadata">

**Author:** ![jack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cc9497/32.png) [@jack](https://www.ruby-forum.com/u/jack)\
**Post date:** [September 10, 2006, 5:50am UTC](https://www.ruby-forum.com/t/why-isnt-order-working-in-acts-as-list/68179/4 "2006-09-10T05:50:10Z")

</div>

On 9/9/06, Michael C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > > getting annoying…  
> > > > position without being able to override it would be less than optimal…
> 
> Rails is opinionated software. =)

And now that I say that, I see …

[http://api.rubyonrails.org/classes/ActiveRecord/Acts/List/ClassMethods.html#M000571](http://api.rubyonrails.org/classes/ActiveRecord/Acts/List/ClassMethods.html#M000571)

acts\_as\_list(options = {})

Configuration options are:

```
* column - specifies the column name to use for keeping the

```

position integer (default: position)

There you go. (Although the example shows “:order” instead of  
“:column” as the option for that; might need to try both.)

---

<div class="post-metadata">

**Author:** ![jack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cc9497/32.png) [@jack](https://www.ruby-forum.com/u/jack)\
**Post date:** [September 10, 2006, 5:46am UTC](https://www.ruby-forum.com/t/why-isnt-order-working-in-acts-as-list/68179/5 "2006-09-10T05:46:09Z")

</div>

On 9/9/06, jack [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > Any help or thoughts would be great. Thanks!
> > 
> > I think ‘acts\_as\_list’ assumes you have a “position” column in your  
> > table (that it manages), and ordering is always by that column, no?
> 
> Hmm…at first I thought you were mistaken, but now that I think about  
> it, maybe I’m just getting this wrong? hmm…i’ll have to look around  
> more…it does seem that forcing a programmer to use a column only named  
> position without being able to override it would be less than optimal…

Rails is opinionated software. =)

---

<div class="post-metadata">

**Author:** ![jack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cc9497/32.png) [@jack](https://www.ruby-forum.com/u/jack)\
**Post date:** [September 10, 2006, 6:06am UTC](https://www.ruby-forum.com/t/why-isnt-order-working-in-acts-as-list/68179/6 "2006-09-10T06:06:12Z")

</div>

Michael C. wrote:

> On 9/9/06, Michael C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > > > > getting annoying…  
> > > > > position without being able to override it would be less than optimal…
> > 
> > Rails is opinionated software. =)
> 
> And now that I say that, I see …
> 
> [http://api.rubyonrails.org/classes/ActiveRecord/Acts/List/ClassMethods.html#M000571](http://api.rubyonrails.org/classes/ActiveRecord/Acts/List/ClassMethods.html#M000571)
> 
> acts\_as\_list(options = {})
> 
> Configuration options are:
> 
> ```
> * column - specifies the column name to use for keeping the
> 
> ```
> 
> position integer (default: position)
> 
> There you go. (Although the example shows “:order” instead of  
> “:column” as the option for that; might need to try both.)

Yeah, thats exactly it. I just straightened things out, and realize  
:column is the way to go…that example should be fixed tho, as it was  
certainly confusing to me 😉

thanks for the help!

jack
