Sha256: cf116f7756c9c41a306116a31a27a33739ab15c5586270bc233a12b7672a0da7
Contents?: true
Size: 730 Bytes
Versions: 3
Compression:
Stored size: 730 Bytes
Contents
module RailsPagination module ActiveRecord module Base def inherited(subclass) if subclass.superclass == ::ActiveRecord::Base subclass.scope :page, Proc.new {|number| subclass.limit(subclass.default_per_page).offset(subclass.default_per_page * ([number.to_i, 1].max - 1)) } do include RailsPagination::ActiveRecord::Relation end end end def default_per_page(value=nil) unless value.nil? value = [value.to_i, 1].max @default_per_page = value end defined?(@default_per_page).nil? ? Rails.application.config.pagination.default_per_page : @default_per_page end end end end
Version data entries
3 entries across 3 versions & 1 rubygems