mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
change scope to class method
This commit is contained in:
parent
6471b9343e
commit
92052eedf0
1 changed files with 7 additions and 5 deletions
|
@ -6,14 +6,16 @@ module Kaminari
|
|||
|
||||
included do
|
||||
self.send(:include, Kaminari::ConfigurationMethods)
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
# Fetch the values at the specified page number
|
||||
# Model.page(5)
|
||||
self.scope Kaminari.config.page_method_name, Proc.new {|num|
|
||||
limit(default_per_page).offset(default_per_page * ([num.to_i, 1].max - 1))
|
||||
} do
|
||||
include Kaminari::ActiveRecordRelationMethods
|
||||
include Kaminari::PageScopeMethods
|
||||
define_method(Kaminari.config.page_method_name) do |num = nil|
|
||||
limit(default_per_page).offset(default_per_page * ([num.to_i, 1].max - 1)).extending do
|
||||
include Kaminari::ActiveRecordRelationMethods
|
||||
include Kaminari::PageScopeMethods
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue