#
In
#
: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
COUNTquery to get the count - an
OFFSET+LIMITquery to get the records
It fully supports all the helpers and navigators.
Controller
@pagy, @records = pagy(:offset, collection, **options)
@pagyis the pagination instance. It provides thereaders and the helpers to use in your code.@recordsrepresents the paginated collection of records for the page (lazy-loaded records).
count_over: true- Use this option with
GROUP BYcollections to calculate the total number of results usingCOUNT(*) OVER ().
- Use this option with
raise_range_error: true- Enable the
Pagy::RangeError(which is otherwise rescued to an empty page by default).
- Enable the
See also Common Options
offset- The OFFSET used in the SQL query
count- The collection count
from- The position in the collection of the first item on the page. (Different Pagy classes may use different value types for it).
to- The position in the collection of the last item on the page. (Different Pagy classes may use different value types for it).
in- The actual items in the page
previous- The previous page
last- The last page
records- The fetched records for the current page.
See also Common Readers
Pagy::RangeError- A subclass of
Pagy::OptionError. Raised for out-of-range:pagerequests, when theraise_range_error: trueoption is enabled.
- A subclass of
See also Common Exceptions