Why isn't :order working in acts_as_list

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

On 9/9/06, jack [email protected] 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?

Michael C. wrote:

On 9/9/06, jack [email protected] 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…

On 9/9/06, Michael C. [email protected] 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

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.)

On 9/9/06, jack [email protected] 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. =)

Michael C. wrote:

On 9/9/06, Michael C. [email protected] 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

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 :wink:

thanks for the help!

jack