Skip to content

Instantly share code, notes, and snippets.

@john-hamnavoe
john-hamnavoe / rails_7_pagy_ransack.md
Last active May 21, 2025 02:07
How I set up pagy and ransack for simple rails 7 application

Introduction

Adding pagy and ransack in rails so can have search function, paging and sorting on table of date on index controller. We also will use kredis to make it easy to store users last search/sort etc. between pages.

Install

Gemfile:

gem "pagy" gem "ransack"

Before Beginning

Make sure https://github.com/excid3/tailwindcss-stimulus-components are installed. Follow the instructions to install them:

  • yarn add tailwindcss-stimulus-components
  • add following to javascript\controllers\index.js:
// Import and register all TailwindCSS Components
import { Alert, Dropdown, Modal, Tabs, Popover, Toggle, Slideover } from "tailwindcss-stimulus-components"