Use Kaminari.config to specify default value for param_name

This commit is contained in:
Sergey Avseyev 2011-04-22 13:26:11 +03:00
parent e9c5d02ec6
commit 5bd0ccc681
3 changed files with 9 additions and 1 deletions

View File

@ -22,6 +22,7 @@ module Kaminari
config_accessor :outer_window
config_accessor :left
config_accessor :right
config_accessor :param_name
end
# this is ugly. why can't we pass the default value to config_accessor...?
@ -31,5 +32,6 @@ module Kaminari
config.outer_window = 0
config.left = 0
config.right = 0
config.param_name = :page
end
end

View File

@ -18,7 +18,7 @@ module Kaminari
# * <tt>:remote</tt> - Ajax? (false by default)
# * <tt>:ANY_OTHER_VALUES</tt> - Any other hash key & values would be directly passed into each tag as :locals value.
def paginate(scope, options = {}, &block)
Kaminari::Helpers::Paginator.new self, options.reverse_merge(:current_page => scope.current_page, :num_pages => scope.num_pages, :per_page => scope.limit_value, :param_name => :page, :remote => false)
Kaminari::Helpers::Paginator.new self, options.reverse_merge(:current_page => scope.current_page, :num_pages => scope.num_pages, :per_page => scope.limit_value, :param_name => Kaminari.config.param_name, :remote => false)
end
end
end

View File

@ -40,4 +40,10 @@ describe Kaminari::Configuration do
its(:right) { should == 0 }
end
end
describe 'param_name' do
context 'by default' do
its(:param_name) { should == :page }
end
end
end