# Countless Extra

In 

Paginate without the need of any count, saving one query per rendering.

# Setup

pagy.rb (initializer)
require 'pagy/extras/countless'

# Modes

This extra uses the Pagy::Countless subclass internally. You can use it in two different modes by enabling the :countless_minimal variable (or not).

# Usage


Controller (eager loading)
@pagy, @records = pagy_countless(some_scope, ...)

This mode fetches limit + 1 and uses the number of fetched records to calculate the variables. It then removes the eventual extra item from the result, so deducing whether there is a next page or not without the need of an extra query.

# Set Up countless_minimal mode


pagy.rb (initializer)
require 'pagy/extras/countless'
# optionally enable the minimal mode by default
# Pagy::DEFAULT[:countless_minimal] = true

# Usage


Controller (lazy loading)
@pagy, @records = pagy_countless(some_scope, countless_minimal: true, ...)

This mode is enabled by the :countless_minimal variable.

# Variables

Variable Description Default
:countless_minimal enable the countless minimal mode false

# Methods

This method is the same as the generic pagy method (see the pagy doc), however its returned objects will depend on the value of the :countless_minimal variable (see Modes)

This sub-method is similar to the pagy_get_items sub-method, but it is called only by the pagy_countless method. (see the pagy_get_items doc).