A simple pagination API to paginate Mongoid Models.
gem install neat-pages
In your Gemfile:
gem 'neat-pages'
First you need to link the assets.
In your css manifest put : require neat_pages
In your javascript manifest put : require neat_pages
You only need to require the javascript if you use the AJAX functionnality.
That's it.
In your controller (app/controllers/products_controller.rb)
def index
paginate
@products = Product.all.paginate(pagination)
end
In your view (app/views/products/index.html.erb)
<%= render 'products', products: @products %>
<%= neat_pages_navigation %>
In your controller (app/controllers/products_controller.rb)
def index
paginate
@products = Product.all.paginate(pagination)
end
In your view (app/views/products/index.html.erb)
<%= neat_pages_ajax_items 'products', products: @products %>
<%= neat_pages_navigation %>
Create the file app/views/products/index.neatpage.erb and place the following code in it.
<% self.formats = ["html"] %>
<%= render 'products', products: @products %>
Triggered on 'body'
whenever a page has changed, from cache or from server.
The event data is an object literal which holds those fields:
noPage
The current page number
If you want to translate the text in the pagination helpers, just add the following keys in i18n.
fr:
neat_pages:
next_page: Page suivante
previous_page: Page précédente
Copyright (c) 2013 De Marque inc. See LICENSE for further details.