README.md in pagers-3.1.5 vs README.md in pagers-4.0.0.0
- old
+ new
@@ -3,12 +3,20 @@
[![Build Status](https://travis-ci.org/mmontossi/pagers.svg)](https://travis-ci.org/mmontossi/pagers)
[![Dependency Status](https://gemnasium.com/mmontossi/pagers.svg)](https://gemnasium.com/mmontossi/pagers)
# Pagers
-Minimalistic pagers inspired in kaminari and will_paginate for rails.
+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 [indexes gem](https://github.com/mmontossi/indexes).
+
## Install
Put this line in your Gemfile:
```ruby
gem 'pagers'
@@ -21,51 +29,56 @@
## Configuration
Generate the configuration file:
```
-rails g pagers:install
+$ bundler exec rails g pagers:install
```
-The defaults values are:
+Set the global settings:
```ruby
Pagers.configure do |config|
+
config.length = 20
config.padding = 0
- config.parameter = :page
- config.pages = 5
+ config.links = 5
+
end
```
## Usage
+### Relation
+
Call the page scope from your models:
```ruby
-@collection = Model.page(1, length: 10, padding: 4)
+@products = Product.page(1)
```
-And in your views just:
+You can override global options by passing a hash:
+```ruby
+@products = Product.page(1, length: 10, padding: 4)
+```
+
+### Views
+
+You can use paginate helper to generate a pager html:
```erb
<%= paginate @collection %>
```
-NOTE: You can override the parameters in the scope and in the helper.
+### SEO
-## SEO
-
-You can add the parameter to paths:
+If you want to remove the page query parameter, add an optional parameter to the route:
```ruby
get 'search/:query/(:page)' => 'products#search'
```
-To produce routes like:
+That will produce links like this:
```
search/sample
search/sample/2
search/sample/3
-.
-.
-.
```
## Credits
This gem is maintained and funded by [mmontossi](https://github.com/mmontossi).