From f9f529fb68ab89feea38773a4c625c1b14859128 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Tue, 22 Feb 2011 02:33:36 +0900 Subject: [PATCH] fixes #10 add :param_name option to the helper example: <%= paginate @users, :param_name => :pagina %> --- lib/kaminari/helpers/action_view_extension.rb | 3 ++- lib/kaminari/helpers/tags.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/kaminari/helpers/action_view_extension.rb b/lib/kaminari/helpers/action_view_extension.rb index aaaf225..56ddafa 100644 --- a/lib/kaminari/helpers/action_view_extension.rb +++ b/lib/kaminari/helpers/action_view_extension.rb @@ -14,10 +14,11 @@ module Kaminari # * :left - The "left outer window" size (1 by default). # * :right - The "right outer window" size (1 by default). # * :params - url_for parameters for the links (:controller, :action, etc.) + # * :param_name - parameter name for page number in the links (:page by default) # * :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::PaginationRenderer.new self, options.reverse_merge(:current_page => scope.current_page, :num_pages => scope.num_pages, :per_page => scope.limit_value, :remote => false) + Kaminari::Helpers::PaginationRenderer.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) end end end diff --git a/lib/kaminari/helpers/tags.rb b/lib/kaminari/helpers/tags.rb index 6fdb13a..0cb564f 100644 --- a/lib/kaminari/helpers/tags.rb +++ b/lib/kaminari/helpers/tags.rb @@ -19,6 +19,7 @@ module Kaminari class Tag def initialize(template, options = {}) #:nodoc: @template, @options = template, template.options.merge(options) + @param_name = @options.delete :param_name end def to_s(locals = {}) #:nodoc: @@ -47,7 +48,7 @@ module Kaminari end def page_url_for(page) - @template.url_for @template.params.merge(:page => (page <= 1 ? nil : page)) + @template.url_for @template.params.merge(@param_name => (page <= 1 ? nil : page)) end end