Module: NextPage::Pagination
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/next_page/pagination.rb
Overview
# Pagination
Module Pagination provides pagination for ActiveRecord queries. It assigns a limit and offset to the resource query and extends the relation with mixin NextPage::PaginationAttributes.
## Invoking Pagination
To paginate a resource pass the resource into method ‘paginate_resource` then store the return value back in the resource:
@photos = paginate_resource(@photos)
Instance Method Summary collapse
Instance Method Details
#paginate_resource(resource, default_limit: nil) ⇒ Object
28 29 30 |
# File 'lib/next_page/pagination.rb', line 28 def paginate_resource(resource, default_limit: nil) self.class.next_page_paginator.paginate_resource(resource, params.fetch(:page, {}), default_limit) end |