Sha256: 8e08e6defee66cabd7b50ae56382d8c6ff6d6c8f5482469ac08833e454e9186f
Contents?: true
Size: 951 Bytes
Versions: 4
Compression:
Stored size: 951 Bytes
Contents
module Rao module ResourcesController::KaminariConcern extend ActiveSupport::Concern included do helper_method :paginate? helper_method :per_page end private def paginate? true end def per_page_default Rao::ResourcesController::Configuration.pagination_per_page_default end def load_collection @collection = load_collection_scope.page(params[:page]).per(per_page) end def per_page # Return page size from configuration if per_page is not present in params unless params.has_key?(:per_page) return per_page_default end # Return count of all records or nil if no records present if # params[:per_page] equals 'all'. Otherwise return params[:per_page] if params[:per_page] == 'all' count = load_collection_scope.count count > 0 ? count : nil else params[:per_page] end end end end
Version data entries
4 entries across 4 versions & 1 rubygems