1
0
Fork 0
mirror of https://github.com/kaminari/kaminari.git synced 2022-11-09 13:44:37 -05:00

fixes #4 works on AR 3.0.0 and 3.0.1 now

this was caused by an AR's bug that offset was not defined on AR::Base < 3.0.2
see: https://rails.lighthouseapp.com/projects/8994/tickets/5688
This commit is contained in:
Akira Matsuda 2011-02-11 20:30:28 +09:00
parent caadaa6553
commit e692254805

View file

@ -15,11 +15,11 @@ module Kaminari
kls.class_eval do
# page(5)
scope :page, lambda {|num|
offset(PER_PAGE * ([num.to_i, 1].max - 1)).limit(PER_PAGE)
limit(PER_PAGE).offset(PER_PAGE * ([num.to_i, 1].max - 1))
} do
# page(3).per(10)
def per(num)
offset(offset_value / limit_value * num).limit(num)
limit(num).offset(offset_value / limit_value * num)
end
def num_pages