Closed triplepointfive closed 1 year ago
Later on, I need to filter it more and recall paginate since it cached the total count with the previous result.
Hi, it would be helpful to share the entire snippet of logic you're trying to do, including the version of Sequel you're using. But just by reading your description, one thing that stands out to me is that you need to re-paginate the same scope that you've already paginated, and I don't think that would work. Is it an option for you to create a whole new scope from scratch?
sequel version 5.53.0
Yes, I can fix it differently, including re implementing original scope. My point is calling paginate
twice shouldn't fail with such error ArgumentError: wrong number of arguments (given 1, expected 0)
Thanks for reporting, but I would say that calling paginate
on an already paginated collection isn't supported and that the workaround would be to restrict your app to call paginate
on a scope only once.
In sequel, I have a long scope with pagination in it, like:
scope = User.where(id: ids1).paginate(page, size)
Later on, I need to filter it more and recall paginate since it cached the total count with the previous result. Without will_paginate I can do it like
scope = scope.where(id: ids2).limit(nil).paginate(page, size)
But with the gem installed, it fails with
Ideas
This method should probably respect calling with an argument: https://github.com/mislav/will_paginate/blob/master/lib/will_paginate/sequel.rb#L33
Or calling
paginate
resets limits & offset by itselfOr adding
remove_pagination
method to remove the limit & offset