Going down the line of Rails history, I was one of those people who admired the in-built pagination feature of Rails. Then later on as we progressed to Rails2 this was plugged out and that's when will_paginate got popularized as both gem and plug-in. It became part of every application that I had built of course varying with different CSS, styles. With advent of Rails3 and unsupported will_paginate had pushed us to move on with alternatives... here come Kaminari
So straight away, jumping on to the point it's pagination gem supporting Rails3. Kaminari is based on Scope & Engine (like rails engine!). It is simple, powerful
- Scope based API
- I18n customizable helper
- ORM & Template engine supported
- Supports HTML5
- Flavored with themes
There are quite number of themes, recipes available for Kaminari. For users coming from will_paginate there are two striking difference to be noted in implementation
Considering we are paginating over the list of posts....
will_paginate
@posts = Post.paginate(:page => params[:page], :per_page => 10)kaminari
@posts = Post.page(params[:page]).per(10)
On to the views...
will_paginate
will_paginate @postskaminari
paginate @posts
Kaminari - https://github.com/amatsuda/kaminari
Recipes - https://github.com/amatsuda/kaminari/wiki/Kaminari-recipes
No comments:
Post a Comment