We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This is more of a question about the usage of this Gem.
I am using api-pagination in combination with pagy to provide a paginated API. This might be as simple as the example shown here.
api-pagination
pagy
Internally api-pagination calls pagy via Pagy.new; here you can also see the offset and limit being applied.
Pagy.new
How would I make this work with fast_page?
fast_page
When I add the method from the README to my controller, it is not being called.
The text was updated successfully, but these errors were encountered:
For now I was able to monkey-patch my way out of this issue by simply adding this to the controller:
module ApiPagination class << self def paginate_with_pagy(collection, options) if Pagy::DEFAULT[:max_per_page] && options[:per_page] > Pagy::DEFAULT[:max_per_page] options[:per_page] = Pagy::DEFAULT[:max_per_page] elsif options[:per_page] <= 0 options[:per_page] = Pagy::DEFAULT[:items] end pagy = pagy_from(collection, options) collection = if collection.respond_to?(:offset) && collection.respond_to?(:limit) collection.offset(pagy.offset).limit(pagy.items).fast_page else collection[pagy.offset, pagy.items] end return [collection, pagy] end end end
Notice the addition lf .fast_page in one of the lines.
.fast_page
But there is probably a cleaner way to do this…
Sorry, something went wrong.
Thanks @slhck! I'm going to look at this more when I have a chance.
I'm expecting your way of overriding the method is probably best. Also possible pagy may have changed since I last used it with fast_page.
I'll see if I can find a nicer way, if not, will update the readme.
No branches or pull requests
This is more of a question about the usage of this Gem.
I am using
api-pagination
in combination withpagy
to provide a paginated API.This might be as simple as the example shown here.
Internally
api-pagination
callspagy
viaPagy.new
; here you can also see the offset and limit being applied.How would I make this work with
fast_page
?When I add the method from the README to my controller, it is not being called.
The text was updated successfully, but these errors were encountered: