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

Merged
merged 1 commit into from Apr 24, 2013

Projects

None yet

3 participants

@pdf
pdf commented Feb 28, 2013

If we have:

class Person
   default_scope order('id ASC')
end

search = Search.new(Person)
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.

@kpassapk

+1

@kpassapk

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

Thoughts?

@radar
Member
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
e3914b8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment