order not honored with uniq
-
Chris Wanstrath
- Assigned user changed from Chris Wanstrath to Mislav
- State changed from new to open
-
Mislav
- State changed from open to invalid
Hey Shirl,
This is in fact your fault. You're mixing database operations with local ones (the uniq method on Arrays). This is not a good approach, since you are using pagination which means all logic should be handled on database level.
Also, uniq has no effect on the result of an ActiveRecord find/paginate because every record returned is unique (primary keys, remember?).
You could try something like:
@person.movies.paginate :select => "DISTINCT title, year", :page => params[:page], :order => params[:sort]Other solution could be using GROUP BY in SQL.
You can post to our discussion Google group to explain why did you try `uniq` in the first place and ask for advice how to solve it on the database level.
-
sjh
adding :select => 'DISTINCT movies.*' worked! Thanks for your help.
-
Mislav
- Tag set to will_paginate
- State changed from invalid to resolved
- Milestone order changed from 0 to 0
(from [8ce22768c1f9f19c86e50babe1eeac5f5f9741b0]) Active Record: fix empty? on a relation with a group clause
Fixes #161, fixes #167
https://github.com/mislav/will_paginate/commit/8ce22768c1f9f19c86e5...
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
