Project

pageable

0.0
No commit activity in last 3 years
No release in over 3 years
Inspired in kaminari and will_paginate but more minimalistic.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 3.0.0
 Project Readme

Gem Version Code Climate Build Status Dependency Status

Pagers

Scope based pagination engine for rails.

Why

I did this gem to:

  • Simplify code by keep close integration with rails.
  • Have most common used settings set out of the box.
  • Create a compatible pagination for indexers gem.

Install

Put this line in your Gemfile:

gem 'pagers'

Then bundle:

$ bundle

Configuration

Generate the configuration file:

$ bundler exec rails g pagers:install

Set the global settings:

Pagers.configure do |config|

  config.length = 20
  config.padding = 0
  config.links = 5

end

Usage

Relation

Call the page scope from your models:

@products = Product.page(1)

You can override global options by passing a hash:

@products = Product.page(1, length: 10, padding: 4)

Views

You can use paginate helper to generate a pager html:

<%= paginate @collection %>

SEO

If you want to remove the page query parameter, add an optional parameter to the route:

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

That will produce links like this:

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

Contributing

Any issue, pull request, comment of any kind is more than welcome!

I will mainly ensure compatibility to Rails, AWS, PostgreSQL, Redis, Elasticsearch and FreeBSD. 

Credits

This gem is maintained and funded by museways.

License

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