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.8.4 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.8.3 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.8.2 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.8.1 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.8.0 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.7.4 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.7.3 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.7.2 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.7.1 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.7.0 app/controllers/concerns/decidim/paginable.rb
decidim-core-0.6.8 app/controllers/concerns/decidim/paginable.rb
decidim-0.6.8 decidim-core/app/controllers/concerns/decidim/paginable.rb
decidim-core-0.6.7 app/controllers/concerns/decidim/paginable.rb
decidim-0.6.7 decidim-core/app/controllers/concerns/decidim/paginable.rb
decidim-core-0.6.6 app/controllers/concerns/decidim/paginable.rb
decidim-0.6.6 decidim-core/app/controllers/concerns/decidim/paginable.rb
decidim-core-0.6.5 app/controllers/concerns/decidim/paginable.rb
decidim-0.6.5 decidim-core/app/controllers/concerns/decidim/paginable.rb
decidim-core-0.6.4 app/controllers/concerns/decidim/paginable.rb
decidim-0.6.4 decidim-core/app/controllers/concerns/decidim/paginable.rb