I came across and issue today that involved my pagination not working correctly. What was happening was a user would do a search with various criteria and the result would show with pagination links. Once they clicked on a new page, it would return them to a list of results, but that wasn’t using any criteria. The solution was fairly simple, but not obviously documented. (Unless you look in the source files)
= will_paginate @object, :params => { :custom_param => @custom_param_value }
Here are some additional custom params you can use:
Display options
- :previous_label — default: “<< Previous” (this parameter is called :prev_label in versions 2.3.2 and older!)
- :next_label — default: “Next >>”
- :page_links — when false, only previous/next links are rendered (default: true)
- :inner_window — how many links are shown around the current page (default: 4)
- :outer_window — how many links are around the first and the last page (default: 1)
- :separator — string separator for page HTML elements (default: single space)
HTML options
- :class — CSS class name for the generated DIV (default: “pagination”)
- :container — toggles rendering of the DIV container for pagination links, set to false only when you are rendering your own pagination markup (default: true)
- :id — HTML ID for the container (default: nil). Pass +true+ to have the ID automatically generated from the class name of objects in collection: for example, paginating ArticleComment models would yield an ID of “article_comments_pagination”.
Advanced options
- :param_name — parameter name for page number in URLs (default: :page)
- :params — additional parameters when generating pagination links (eg. :controller => “foo”, :action => nil)
- :renderer — class name, class or instance of a link renderer (default: WillPaginate::LinkRenderer)