From d79c94626c6cf77543add46eafc24afe8ee71408 Mon Sep 17 00:00:00 2001 From: Yuki Nishijima Date: Tue, 18 Jun 2013 22:30:05 +0900 Subject: [PATCH] Revert "Merge pull request #304 from bricker88/nil_for_per" This reverts commit 38fb04fab3e6c094a2325ce5e9d9d34051095c07, reversing changes made to 992fb9f935ca6290d4abf931e935cab4e1fd5b5a. Conflicts: README.rdoc spec/models/active_record/scopes_spec.rb --- README.rdoc | 4 ---- lib/kaminari/models/page_scope_methods.rb | 4 +--- spec/models/active_record/scopes_spec.rb | 5 ----- 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/README.rdoc b/README.rdoc index 9c2901a..11cd71a 100644 --- a/README.rdoc +++ b/README.rdoc @@ -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 diff --git a/lib/kaminari/models/page_scope_methods.rb b/lib/kaminari/models/page_scope_methods.rb index b59cd59..b47134a 100644 --- a/lib/kaminari/models/page_scope_methods.rb +++ b/lib/kaminari/models/page_scope_methods.rb @@ -3,9 +3,7 @@ module Kaminari # Specify the per_page value for the preceding page 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) diff --git a/spec/models/active_record/scopes_spec.rb b/spec/models/active_record/scopes_spec.rb index c7f7b69..ea42d70 100644 --- a/spec/models/active_record/scopes_spec.rb +++ b/spec/models/active_record/scopes_spec.rb @@ -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