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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 9/9/06, jack <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > 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!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? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Michael Campbell wrote:> On 9/9/06, jack <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> 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... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 9/9/06, jack <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Michael Campbell wrote: > > On 9/9/06, jack <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> 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...Rails is opinionated software. =) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 9/9/06, Michael Campbell <michael.campbell-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 9/9/06, jack <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > > Michael Campbell wrote: > > > On 9/9/06, jack <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> 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... > > > 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.) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Michael Campbell wrote:> On 9/9/06, Michael Campbell <michael.campbell-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 ;-) thanks for the help! jack -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---