<img src=“https://codeclimate.com/github/mattways/rails_pagination.png” /> <img src=“https://secure.travis-ci.org/mattways/rails_pagination.png?branch=master” alt=“Build Status” /> <img src=“https://gemnasium.com/mattways/rails_pagination.png” alt=“Dependency Status” />

Rails Pagination

Inspired in kaminari and will_paginate but more minimalistic

Install

Put this line in your Gemfile:

gem 'rails_pagination'

Then bundle:

$ bundle

Usage

The same approach as kaminari:

Model.page(1).per(20)

You can use the default html with this helper:

pager @collection

Or you can make your own just paginating the collection:

paginate @collection # Loot at app/views/rails_pagination/_pager.html.erb

Configuration

Default param name

If you want to change the default parameter name or the default navigation length call pager/paginate this way:

pager @collection, navigation: 3, parameter: :p

Or to set it globally put this in your application.rb:

config.pagination.default_parameter = :p
config.pagination.default_navigation = 5

Default per page

If you want to change the default per_page put this in your model:

default_per_page 5

Or to set it globally put this in your application.rb:

config.pagination.default_per_page = 5

Padding

You can use positive and negative padding:

Model.page(1).per(10).pad(-4)