Back to Pagy

Offset

docs/toolbox/paginators/offset.md

43.5.31.1 KB
Original Source

:icon-move-to-end:  :offset


:offset is a generic OFFSET paginator usable with ORM collections or regular Array objects.

It uses the complete OFFSET pagination technique, which triggers two SQL queries per request:

  • a COUNT query to get the count
  • an OFFSET + LIMIT query to get the records

It fully supports all the helpers and navigators.

!!!warning Consider using the :countish paginator when possible! The :countish paginator offers identical UI features, but it's up to 2x faster. !!!

=== :icon-tools:  Usage

ruby
@pagy, @records = pagy(:offset, collection, **options)
  • @pagy is the pagination instance. It provides the readers and the helpers to use in your code.
  • @records represents the paginated collection of records for the page (lazy-loaded records).

==- :icon-sliders:  Options

{{ include "options/offset" }}

==- :icon-mention:  Readers

{{ include "snippets/offset-readers" }}

===