It’s Easy to Use Kaminari on RoR 3.2

Now let’s talk about codes again.

I have this simple experience on using Kaminari, a pagination plugin for Ruby on Rails. I’ve used will_paginate for sometime, but I just want to use something else and I found Kaminari is easier to use, IMO. So, let me tell you how to set this up for basic use.

  1. Put this code on your Gemfile : gem "kaminari"
  2. Run bundle install
  3. Go to your controller file, let’s say we have model named User. So we can get paged set of User data with this code :[:page]).per(20).
  4. Now you may ask this : how can I make a custom view for my pagination links? It’s very easy. You can start by running this code first : rails g kaminari:views default.
  5. That command will generate some files in app/views/kaminari. Go to that directory and make your own style for your pagination links.

That’s it guys. You’re now having kaminari on your site for basic use. You can go to Kaminari origin site to find more information about this plugin. So use it now for your app and have a fun time using it.