Revert "Merge pull request #304 from bricker88/nil_for_per"

This reverts commit 38fb04fab3, reversing
changes made to 992fb9f935.

Conflicts:

	README.rdoc
	spec/models/active_record/scopes_spec.rb
This commit is contained in:
Yuki Nishijima 2013-06-18 22:30:05 +09:00
parent 0a20c22aed
commit d79c94626c
3 changed files with 1 additions and 12 deletions

View File

@ -62,10 +62,6 @@ Then bundle:
To show a lot more users per each page (change the +per_page+ value)
User.page(7).per(50)
Note that the +per+ scope is not directly defined on the models but is just a method defined on the page scope. This is absolutely reasonable because you will never actually use +per_page+ without specifying the +page+ number.
If you would like to specify "no limit" while still using the +per+ scope, you can pass +nil+:
User.count # => 1000
User.page(1).per(nil).size # => 1000
Keep in mind that +per+ utilizes internally +limit+ and so it will override any +limit+ that was set previously
User.count # => 1000

View File

@ -3,9 +3,7 @@ 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 num.nil?
limit(nil)
elsif (n = num.to_i) <= 0
if (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,11 +58,6 @@ 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