Skip to content
Browse files

Change default value of max_per_page from 0 to nil

  • Loading branch information...
1 parent c778676 commit 7af1e87db47f21d05eef3a0cc9e2e58c36f0b704 @keiko713 keiko713 committed Aug 28, 2012
Showing with 6 additions and 6 deletions.
  1. +2 −2 README.rdoc
  2. +1 −1 lib/kaminari/config.rb
  3. +1 −1 lib/kaminari/models/page_scope_methods.rb
  4. +2 −2 spec/config/config_spec.rb
View
4 README.rdoc
@@ -73,7 +73,7 @@ Then bundle:
You can configure the following default values by overriding these values using <tt>Kaminari.configure</tt> method.
default_per_page # 25 by default
- max_per_page # 0 by default
+ max_per_page # nil by default
window # 4 by default
outer_window # 0 by default
left # 0 by default
@@ -104,7 +104,7 @@ Run the following generator command, then edit the generated file.
* +max_paginates_per+
You can specify max +per_page+ value per each model using the following declarative DSL.
- If the variable that specified via +per+ scope is more than this variable, max +paginates_per+ is used instead of it. Default value is 0, which means you are not specifying max +per_page+ value.
+ If the variable that specified via +per+ scope is more than this variable, max +paginates_per+ is used instead of it. Default value is nil, which means you are not imposing any max +per_page+ value.
class User < ActiveRecord::Base
max_paginates_per 100
end
View
2 lib/kaminari/config.rb
@@ -38,7 +38,7 @@ def param_name
# this is ugly. why can't we pass the default value to config_accessor...?
configure do |config|
config.default_per_page = 25
- config.max_per_page = 0
+ config.max_per_page = nil
config.window = 4
config.outer_window = 0
config.left = 0
View
2 lib/kaminari/models/page_scope_methods.rb
@@ -5,7 +5,7 @@ module PageScopeMethods
def per(num)
if (n = num.to_i) <= 0
self
- elsif max_per_page != 0 && max_per_page < n
+ elsif max_per_page && max_per_page < n
limit(max_per_page).offset(offset_value / limit_value * max_per_page)
else
limit(n).offset(offset_value / limit_value * n)
View
4 spec/config/config_spec.rb
@@ -19,15 +19,15 @@
describe 'max_per_page' do
context 'by default' do
- its(:max_per_page) { should == 0 }
+ its(:max_per_page) { should == nil }
end
context 'configure via config block' do
before do
Kaminari.configure {|c| c.max_per_page = 100}
end
its(:max_per_page) { should == 100 }
after do
- Kaminari.configure {|c| c.max_per_page = 0}
+ Kaminari.configure {|c| c.max_per_page = nil}
end
end
end

0 comments on commit 7af1e87

Please sign in to comment.
Something went wrong with that request. Please try again.