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.
- Put this code on your Gemfile :
- Go to your controller file, let’s say we have model named
User. So we can get paged set of
Userdata with this code :
- 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.
- 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.