Actually it's doing multiple field ordering... It's best to think of the orders as compounding not replacing each other. Easiest to see if you have two different cols rather than the same one... For example created_at desc, name asc will sort on creation date and then name... So for all records where the dates are identical, it will then sort on name alpha ascending... Understand?
Blog: http://random8.zenunit.com/ Twitter: http://twitter.com/random8r Learn: http://sensei.zenunit.com/ New video up now at http://sensei.zenunit.com/ real fastcgi rails deploy process! Check it out now! On 17/02/2011, at 4:38 AM, Colin Law <clan...@googlemail.com> wrote: > I have found various blogs and comments on the issue of merging order > scopes but have not been able to determine whether the current > situation is regarded as satisfactory. > > Using Rails 3.0.4, the particular case I am considering is > Item.order( 'x DESC').order('x ASC') > This appears to merge the sorts in the wrong order so that the result > is x DESC. The sql generated is > SELECT 'items'.* FROM 'items' ORDER BY id DESC, id ASC > Which results in descending order (SQL is rather non-intuitive here). > > One result is that it is not possible (as far as I can see) to > override a default or named scope that applies a sort order. > > Perhaps I am missing something obvious. > > Colin > > -- > 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@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.