| Path: | lib/routing_filter/filters/pagination.rb |
| Last Update: | Wed Dec 21 14:15:47 +0200 2011 |
The Pagination filter extracts segments matching /page/:page from the end of the recognized url and exposes the page parameter as params[:page]. When a url is generated the filter adds the segments to the url accordingly if the page parameter is passed to the url helper.
incoming url: /products/page/1 filtered url: /products params: params[:page] = 1
You can install the filter like this:
# in config/routes.rb
Rails.application.routes.draw do
filter :pagination
end
To make your named_route helpers or url_for add the pagination segments you can use:
products_path(:page => 1) url_for(:products, :page => 1)