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

Allow nil for #per, to return records without limit

This commit is contained in:
Bryan Ricker 2012-10-31 18:02:52 -07:00
parent 07cd48d293
commit 949f345a50
2 changed files with 8 additions and 1 deletions

View file

@ -3,7 +3,9 @@ module Kaminari
# Specify the <tt>per_page</tt> value for the preceding <tt>page</tt> scope
# Model.page(3).per(10)
def per(num)
if (n = num.to_i) <= 0
if num.nil?
limit(nil)
elsif (n = num.to_i) <= 0
self
elsif max_per_page && max_per_page < n
limit(max_per_page).offset(offset_value / limit_value * max_per_page)

View file

@ -58,6 +58,11 @@ if defined? ActiveRecord
it { should have(5).users }
its('first.name') { should == 'user001' }
end
context "page 1 per nil" do
subject { model_class.page(1).per(nil) }
it { should have(model_class.count).users }
end
end
describe '#padding' do