#73 Pagination with Kaminari


When displaying a significant number of records, it is often a basic functions in a web application is to paginate the records and load them as requested.
rails view 2:37


Gemfilegem 'kaminari'
Terminal# Generate the kaminari config
rails g kaminari:config

# Generate kaminari views
rails g kaminari:views bootstrap3
users_controller.rb  def index
    @users = User.order(:last_name).page(params[:page])
index.html.erb<%= paginate @users %>
user.rbclass User < ApplicationRecord
  paginates_per 5

Pavan Prakash CS said 12 months ago:

Thanks for helping the starters like me with your great work. Can you please do a video on infinite scroll with kaminari? The example used in the wiki of the gem is very old and the JavaScript library is not maintained anymore. 

kobaltz PRO said 12 months ago:

Have a look at https://www.driftingruby.com/episodes/infinite-scrolling

It uses `will_paginate` but `kaminari` should be a fairly simple drop in with some minor changes.

Pavan Prakash CS said 12 months ago:

Thanks for the reply. Thumbs up for all your help. 

Schwad said 11 months ago:

That's really cool, fired up a toy app just to play with Kaminari following this. Thanks for the screencast!

Login to Comment