From 5bd0ccc681538f614a353d00d1810444541fc101 Mon Sep 17 00:00:00 2001 From: Sergey Avseyev Date: Fri, 22 Apr 2011 13:26:11 +0300 Subject: [PATCH] Use Kaminari.config to specify default value for param_name --- lib/kaminari/config.rb | 2 ++ lib/kaminari/helpers/action_view_extension.rb | 2 +- spec/config/config_spec.rb | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/kaminari/config.rb b/lib/kaminari/config.rb index 907670c..d7fc44e 100644 --- a/lib/kaminari/config.rb +++ b/lib/kaminari/config.rb @@ -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 diff --git a/lib/kaminari/helpers/action_view_extension.rb b/lib/kaminari/helpers/action_view_extension.rb index 9cdf7f0..4597841 100644 --- a/lib/kaminari/helpers/action_view_extension.rb +++ b/lib/kaminari/helpers/action_view_extension.rb @@ -18,7 +18,7 @@ module Kaminari # * :remote - Ajax? (false by default) # * :ANY_OTHER_VALUES - 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 diff --git a/spec/config/config_spec.rb b/spec/config/config_spec.rb index 8bae394..f81ff7a 100644 --- a/spec/config/config_spec.rb +++ b/spec/config/config_spec.rb @@ -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