Sha256: d2904f0d23685786f740902b302d04a992cdae8185130334f9550bde46d56f22

Contents?: true

Size: 590 Bytes

Versions: 1

Compression:

Stored size: 590 Bytes

Contents

module Rao
  module ResourcesController::WillPaginateConcern
    extend ActiveSupport::Concern

    included do
      helper_method :paginate?
    end

    def paginate?
      true
    end

    private

    def load_collection
      options = { page: params[:page] }
      options[:per_page] = per_page
      @collection = load_collection_scope.paginate(options)
    end

    def per_page
      if [nil, 'all'].include?(params[:per_page])
        load_collection_scope.count
      else
        Rao::ResourcesController::Configuration.pagination_per_page_default
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rao-resources_controller-0.0.22.pre app/concerns/rao/resources_controller/will_paginate_concern.rb