Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/kolodovskyy/kaminari into…
Browse files Browse the repository at this point in the history
… kolodovskyy-master
  • Loading branch information
yuki24 committed Nov 11, 2013
2 parents e6f266a + 92052ee commit ecd2578
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/kaminari/models/active_record_model_extension.rb
Expand Up @@ -6,14 +6,16 @@ module ActiveRecordModelExtension

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
Expand Down

0 comments on commit ecd2578

Please sign in to comment.