Reorder results to override orders applied up the chain (eg - scopes) #208

merged 1 commit into from Apr 24, 2013


None yet

3 participants

pdf commented Feb 28, 2013

If we have:

class Person
   default_scope order('id ASC')

search =
search.sorts = 'id DESC'

Then the sort will not get applied. We may need to preserve other scopes though, so I've used reorder to force replacing any existing order with our sort.

I added a new spec and default_scope to Person, and all existing specs pass.




This seems OK to me, and I'd really like to see it merged! 👍


radar commented Apr 24, 2013

Seems good to me too. Thanks @pdf.

@radar radar merged commit 764eecb into activerecord-hackery:master Apr 24, 2013

1 check passed

Details default The Travis build passed
@jonatack jonatack added a commit that referenced this pull request May 23, 2013
@jonatack jonatack Merge further elements from spectator's Rails 3 comptability work, me…
…rge pull request #208 from pdf/reorder, use Rails 4 active-record distinct method which replaces uniq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment