:page_facing_up: Link header pagination for Rails and Grape APIs.
Move the definition of ApiPagination::Hooks
to fix booting in Rails 3 and 4 environments (#72)
Add support for Rails 5.
NOTE: The Rails::Pagination
module will no longer be mixed into ActionController::Base
if ActionController::API
is also defined. If for any reason your API controllers cannot easily changed be changed to inherit from ActionController::API
instead, you can manually include Rails::Pagination
in your API's ApplicationController
.
api-pagination now allows developers to manually set a total_page
when paginating Arrays. This is useful when paginating results from external services such as ElasticSearch or other APIs, where you are dealing with Arrays of already-paginated results as opposed to an ActiveRecord collection:
total_count = $redis.llen "ratings"
page, per_page = params.fetch(:page, 1), params.fetch(:per_page, 25)
start = (page - 1) * per_page
results = $redis.lrange "ratings", start, start + per_page
paginate results, paginate_array_options: { total_count: total_count }
Warnings about including both Kaminari and WillPaginate are now deferred until ApiPagination.config.paginator
is called.
Warnings about including both Kaminari and WillPaginate are now deferred until ApiPagination.config.paginator
is called.
Add ApiPagination::Configuration
Add a configuration object that handles names of Total and Per-Page headers, as well as allows for the manual setting of the paginator that ApiPagination will use. It's up to the user to make WillPaginate and Kaminari play nicely together if they include both.
Add ApiPagination::Configuration
Add a configuration object that handles names of Total and Per-Page headers, as well as allows for the manual setting of the paginator that ApiPagination will use. It's up to the user to make WillPaginate and Kaminari play nicely together if they include both.
This release includes compatibility for recent versions of Grape (0.10.0 and later). Unfortunately this is not backwards compatible with previous Grape versions. If using Grape 0.9.x or earlier, continue using api-pagination 3.1.x. This will continue to receive bug fixes.
paginate
to directly accept a collection and return the paginated collection itself instead of implicitly rendering (an implicit render will still happen if the call to paginate
mimics a call to render
)paginate_with
would raise an exception in Rails (#11)per_page
option could not be overridden in Grape (#12)