Skip to content

Commit

Permalink
add :param_name option to the helper
Browse files Browse the repository at this point in the history
example: <%= paginate @users, :param_name => :pagina %>
  • Loading branch information
amatsuda committed Feb 21, 2011
1 parent 0e7a3d8 commit 5826382
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/kaminari/helpers/action_view_extension.rb
Expand Up @@ -14,10 +14,11 @@ module InstanceMethods
# * <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
Expand Down
3 changes: 2 additions & 1 deletion lib/kaminari/helpers/tags.rb
Expand Up @@ -19,6 +19,7 @@ module Helpers
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:
Expand Down Expand Up @@ -47,7 +48,7 @@ def find_template
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

Expand Down

0 comments on commit 5826382

Please sign in to comment.