acts_as_paranoid support for will_paginate
Reported by Diego Algorta | January 30th, 2008 @ 03:08 PM | in will_paginate v3.0 ("agnostic")
I'm using both will_paginate and acts_as_paranoid on a project. AAP adds a scope to the normal find* and count methods to filter all logically deleted records and adds find_with_deleted and count_with_deleted methods to access to the raw records including those deteled.
So currently paginating a find_with_deleted collection works ok, but the page_count keeps using the normal count instead of count_with_deleted resulting in a wrong count of pages.
I'm attaching a PATCH that deals with this as a special case the same way you already do for when using scope_out.
You'll see the patch works both with find_with_deleted and find_only_deleted. The "only" version is a PATCH to acts_as_paranoid I've sent upstream (techno-weenie) without response from him.
Comments and changes to this ticket
-
Mislav January 31st, 2008 @ 08:29 PM
- Assigned user changed from Chris Wanstrath to Mislav
- State changed from new to open
Thanks for the suggestion. I'll not apply the patch immediately because I'm researching how to cover counts generically (without special-casing within the plugin). If I'm successful, then this will work even without the patch.
-
Mislav October 8th, 2008 @ 11:20 PM
- Milestone set to will_paginate v3.0 ("agnostic")
- Tag set to count, will_paginate
-
Diego Algorta October 8th, 2008 @ 11:32 PM
Funny you updated this ticket today... because TODAY, I forked will_paginate on github and applied a more "agnostic" patch that could potentially remove will_paginate's responsibility to "guess" which counter to use depending on the finder.
I've been using my old patch in production since I created it back in January, but now that I'm working on upgrading the app from rails 1.2.6 to 2.1.1 and started using your mislav-willpaginate gem, I wanted to create a patch that you could merge and would benefit all other users and finish this counter guessing problem once and for all.
I didn't send a pull request yet because I was waiting to have it better tested... but... maybe you can look at it. It's a very simplistic fix (includes a test).
http://github.com/oboxodo/will_p...
Please, let me know your thoughts.
-
Mislav October 8th, 2008 @ 11:48 PM
Haha ... we share a telepathic link ;)
I looked at your commit and it looks fair enough, although I believe the solution can be even more generic. I have something in mind but I have to try it out ... Wait a few days until I get a chance to work on the "agnostic" branch more.
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.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
Everyone's favorite Ruby library for pagination of practically anything!