Kaminari adds pagination logic to finders – it works with all kinds of ORMs, e.g. in ActiveRecord. It also gives us a bunch of helpers to render pagination links.
It is extremely popular as it doesn’t pollute objects with pagination logic.
Typically, a controller, an operation or a model will accumulate models to display.
@users = User.order(:name).page params[:page]
Later, in a view, after rendering the rows itself you want to display a link to jump to the next or previous page.
= paginate @users
A really simple and cool thing.
Pagination In Cells.
As kaminari uses global partials to render the pagination links, we had to make it work with cells, which usually does not use global partials. Thanks to the fine kaminari team, this was implemented, tested and merged within hours.
All you need to do to make the
paginate helper work in a cell view is add the gem to your
And then extend the class.
class CommentsCell < Cell::Rails include Kaminari::Cells
This works for both conventional cells and view models.