Change default value of max_per_page from 0 to nil
This commit is contained in:
parent
c77867681e
commit
7af1e87db4
|
@ -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
|
||||
|
|
|
@ -38,7 +38,7 @@ module Kaminari
|
|||
# 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
|
||||
|
|
|
@ -5,7 +5,7 @@ module Kaminari
|
|||
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)
|
||||
|
|
|
@ -19,7 +19,7 @@ describe Kaminari::Configuration do
|
|||
|
||||
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
|
||||
|
@ -27,7 +27,7 @@ describe Kaminari::Configuration do
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue