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.6.3 app/controllers/concerns/decidim/paginable.rb
decidim-0.6.3 decidim-core/app/controllers/concerns/decidim/paginable.rb
decidim-core-0.6.2 app/controllers/concerns/decidim/paginable.rb
decidim-0.6.2 decidim-core/app/controllers/concerns/decidim/paginable.rb
decidim-core-0.6.1 app/controllers/concerns/decidim/paginable.rb
decidim-0.6.1 decidim-core/app/controllers/concerns/decidim/paginable.rb
decidim-core-0.6.0 app/controllers/concerns/decidim/paginable.rb
decidim-0.6.0 decidim-core/app/controllers/concerns/decidim/paginable.rb
decidim-core-0.5.1 app/controllers/concerns/decidim/paginable.rb
decidim-0.5.1 decidim-core/app/controllers/concerns/decidim/paginable.rb
decidim-core-0.5.0 app/controllers/concerns/decidim/paginable.rb
decidim-0.5.0 decidim-core/app/controllers/concerns/decidim/paginable.rb
decidim-core-0.4.4 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.4.2 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.4.1 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.4.3 app/controllers/concerns/decidim/paginable.rb