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…
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?
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…
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…
* 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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.