Mongoid::Paginate
Mongoid::Paginate provides simple pagination for Mongoid ODM.
Installation
Add this line to your application's Gemfile:
gem 'mongoid_paginate'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mongoid_paginate
Usage
class Document
include Mongoid::Document
include Mongoid::Paginate
field :name, type: String
paginate(per_page: 20)
end
# works just like a scope
Document.paginate(params[:page])
# for working in the view, calculate the total number of pages
@pages = Document.pages
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request