Module: Uchi::Pagination::Controller

Includes:
Pagy::Method
Included in:
RepositoryController
Defined in:
lib/uchi/pagination/controller.rb

Instance Method Summary collapse

Instance Method Details

#paginate(records, records_per_page:) ⇒ Array<(Uchi::Pagination::Page, ActiveRecord::Relation)>

Set up pagination for the given records. Returns a Page object and the paginated records for that page.

Parameters:

  • records (ActiveRecord::Relation)

    The records to paginate

  • records_per_page (Integer)

    The number of records per page

Returns:



20
21
22
23
# File 'lib/uchi/pagination/controller.rb', line 20

def paginate(records, records_per_page:)
  page, records = pagy(:offset, records, limit: records_per_page)
  [Uchi::Pagination::Page.new(page), records]
end