Pagy is a recent pagination library for Ruby on Rails.
In this tutorial, we will see how to build a custom pagination component with Rails for paginating large data-sets.
# config/initializer/pagy.rb require ‘pagy/extras/bulma’ require ‘pagy/extras/array’Extras don’t define any new module or class, they just re-open the Pagy class and modules, adding the extra methods as they were part of the loaded pagy gem.
def friends .
# app/controllers/user_controllers.rb class UsersController < ApplicationController def show @ user = User.find(params[:user_id]) @ pagy , @ friends = pagy(@user.friends, items: 3 ) end def index @ users = User.all @ pagy , @ nofriends = pagy(User.all_except(current_user), page: params [ :page ], items: 9 ) end .

Comments to: Paginating Rails with Pagy

Your email address will not be published. Required fields are marked *

Attach images - Only PNG, JPG, JPEG and GIF are supported.

Login

Welcome to Typer

Brief and amiable onboarding is the first thing a new user sees in the theme.
Join Typer
Registration is closed.