1
0
Fork 0
mirror of https://github.com/kaminari/kaminari.git synced 2022-11-09 13:44:37 -05:00
kaminari--kaminari/lib/kaminari/models/active_record_extension.rb
Akira Matsuda e4ec3ad450 goodbye TERRIBLE HORRIBLE NO GOOD VERY BAD HACK!
calling `super` at the bottom does the healthy initialization. Thanks to this commit again! https://github.com/amatsuda/kaminari/commit/cb65a17
2011-04-19 19:01:23 +09:00

25 lines
690 B
Ruby

require File.join(File.dirname(__FILE__), 'active_record_relation_methods')
module Kaminari
module ActiveRecordExtension
extend ActiveSupport::Concern
included do
def self.inherited(kls) #:nodoc:
kls.class_eval do
include Kaminari::ConfigurationMethods
# Fetch the values at the specified page number
# Model.page(5)
scope :page, Proc.new {|num|
limit(default_per_page).offset(default_per_page * ([num.to_i, 1].max - 1))
} do
include Kaminari::ActiveRecordRelationMethods
include Kaminari::PageScopeMethods
end
end
super
end
end
end
end