diff --git a/docs/extras/countless.md b/docs/extras/countless.md index b9a2dde28..e38af983c 100644 --- a/docs/extras/countless.md +++ b/docs/extras/countless.md @@ -25,8 +25,6 @@ In a controller: @pagy, @records = pagy_countless(some_scope, ...) ``` -**Notice**: When using `ActiveRecord`, the `@records` is an `Array`. On the other side, the normal `Pagy` returns an `ActiveRelation`. - ## Files This extra is composed of 1 file: @@ -47,5 +45,7 @@ This sub-method is similar to the `pagy_get_vars` sub-method, but it is called o ### pagy_countless_get_items(collection, pagy) -This sub-method is the same as the `pagy_get_items` sub-method, but it is called only by the `pagy_countless` method. (see the [pagy_get_items doc](../api/backend.md#pagy_get_itemscollection-pagy)). +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](../api/backend.md#pagy_get_itemscollection-pagy)). + +**Notice**: This method calls `to_a` on the collection in order to `pop` the eventual extra item from the result, so it returns an `Array`. That's different than the regular `pagy_get_items` method which doesn't need to call `to_a` on the collection. diff --git a/lib/pagy.rb b/lib/pagy.rb index a1809cded..f0636f94f 100644 --- a/lib/pagy.rb +++ b/lib/pagy.rb @@ -15,7 +15,7 @@ def self.root; Pathname.new(__FILE__).dirname end attr_reader :count, :page, :items, :vars, :pages, :last, :offset, :from, :to, :prev, :next - # Merge and validate the options, do some simple aritmetic and set the instance variables + # Merge and validate the options, do some simple arithmetic and set the instance variables def initialize(vars) @vars = VARS.merge(vars.delete_if{|_,v| v.nil? || v == '' }) # default vars + cleaned vars { count:0, items:1, outset:0, page:1 }.each do |k,min| # validate instance variables