fixes #10 add :param_name option to the helper

example: <%= paginate @users, :param_name => :pagina %>
This commit is contained in:
Akira Matsuda 2011-02-22 02:33:36 +09:00
parent 0e7a3d8350
commit f9f529fb68
2 changed files with 4 additions and 2 deletions

View File

@ -14,10 +14,11 @@ module Kaminari
# * <tt>:left</tt> - The "left outer window" size (1 by default).
# * <tt>:right</tt> - The "right outer window" size (1 by default).
# * <tt>:params</tt> - url_for parameters for the links (:controller, :action, etc.)
# * <tt>:param_name</tt> - parameter name for page number in the links (:page by default)
# * <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::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

View File

@ -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