#
In
#
:offset
:offset
is a generic OFFSET paginator usable with ORM collections and 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.
Controller
@pagy, @records = pagy(:offset, collection, **options)
@pagy
is the pagination instance. It provides thereaders and the helpers to use in your code.@records
represents the paginated collection of records for the page (lazy-loaded records).
count_over: true
- Use this option with
GROUP BY
collections 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:page
requests, when theraise_range_error: true
option is enabled.
- A subclass of
See also Common Exceptions