Method: Kaminari::Helpers::HelperMethods#paginate

Defined in:
lib/kaminari/helpers/helper_methods.rb

#paginate(scope, paginator_class: Kaminari::Helpers::Paginator, template: nil, **options) ⇒ Object

A helper that renders the pagination links.

<%= paginate @articles %>

Options

  • :window - The “inner window” size (4 by default).

  • :outer_window - The “outer window” size (0 by default).

  • :left - The “left outer window” size (0 by default).

  • :right - The “right outer window” size (0 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)

  • :paginator_class - Specify a custom Paginator (Kaminari::Helpers::Paginator by default)

  • :template - Specify a custom template renderer for rendering the Paginator (receiver by default)

  • :ANY_OTHER_VALUES - Any other hash key & values would be directly passed into each tag as :locals value.



116
117
118
119
120
121
122
# File 'lib/kaminari/helpers/helper_methods.rb', line 116

def paginate(scope, paginator_class: Kaminari::Helpers::Paginator, template: nil, **options)
  options[:total_pages] ||= scope.total_pages
  options.reverse_merge! current_page: scope.current_page, per_page: scope.limit_value, remote: false

  paginator = paginator_class.new (template || self), **options
  paginator.to_s
end