Sha256: b7b68a2003b9657f2322fc1d679df215f628f8fc15c01f06fb2eca1026a4e3c1

Contents?: true

Size: 439 Bytes

Versions: 56

Compression:

Stored size: 439 Bytes

Contents

# frozen_string_literal: true

require "active_support/concern"

module Decidim
  # Common logic to paginate resources
  module Paginable
    extend ActiveSupport::Concern

    OPTIONS = [20, 50, 100].freeze

    included do
      helper_method :per_page

      def paginate(resources)
        resources.page(params[:page]).per(per_page)
      end

      def per_page
        params[:per_page] || OPTIONS.first
      end
    end
  end
end

Version data entries

56 entries across 56 versions & 2 rubygems

Version Path
decidim-core-0.14.4 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.14.3 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.14.2 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.14.1 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.13.1 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.12.2 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.13.0 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.12.1 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.13.0.pre1 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.12.0 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.11.2 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.12.0.pre app/controllers/concerns/decidim/paginable.rb
decidim-core-0.11.1 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.11.0.pre1 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.10.1 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.10.0 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.9.3 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.9.2 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.9.1 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.9.0 app/controllers/concerns/decidim/paginable.rb