I have a set of models Dog that I want to created a named_scope/ default_scope so that they load in a certain order - I want to specify a list of ids 3,2,5,1,4 to load in that order. How can I do this? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.
Add a position column to your table and create a default scope for it. default_scope :order => ''position'' --- Nicholas Henry Ruby on Rails Developer nicholas-avpPrnUtcvTqJdGyAr2GoA@public.gmane.org Firsthand Web Design and Development p 514.949.6869 Website http://www.firsthand.ca Twitter http://twitter.com/firsthand Blog http://blog.firsthand.ca/ Fork me on Github http://github.com/firsthand On Nov 18, 2:24 am, eggie5 <egg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have a set of models Dog that I want to created a named_scope/ > default_scope so that they load in a certain order - I want to specify > a list of ids 3,2,5,1,4 to load in that order. How can I do this?-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.
On 18 Nov 2009, at 17:11, Nicholas Henry wrote:> Add a position column to your table and create a default scope for it. > > default_scope :order => ''position''Do remember that (currently) Rails isn''t smart enough to override the parameters in other named scopes: default_scope :conditions => {:active => true} named_scope :inactive, :conditions => {:active => false} Forget it, doesn''t work. Query resolves to SELECT * from table WHERE active=true AND active=false Best regards Peter De Berdt -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=.