Gem Version Code Climate Build Status Dependency Status

Pagers

Minimalistic pagers inspired in kaminari and will_paginate for rails.

Install

Put this line in your Gemfile:

gem 'pagers'

Then bundle:

$ bundle

Configuration

Generate the configuration file:

rails g pagers:install

The defaults values are:

Pagers.configure do |config|
  config.length = 20
  config.padding = 0
  config.parameter = :page
  config.pages = 5
end

Usage

Call the page scope from your models:

@collection = Model.page(1, length: 10, padding: 4)

And in your views just:

<%= paginate @collection %>

NOTE: You can override the parameters in the scope and in the helper.

SEO

You can add the parameter to paths:

get 'search/:query/(:page)' => 'products#search'

To produce routes like:

search/sample
search/sample/2
search/sample/3
.
.
.

Credits

This gem is maintained and funded by mmontossi.

License

It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.