Ruby on Rails #99 Hotwire: Search and Infinite Pagination (Ransack with Pagy)

09/12/2022 (over 1 year ago)

Implementing search or pagination is relatively easy, but it can get tricky when you try to combine the two, especially when you factor in some frontend. In this eposide we will learn to use gem Ransack for search, and gem Pagy for infinite scroll pagination.

Episode source code:

Text version:

0:00 Final app demo with search and pagination
0:55 Boilerplate app
1:20 Ransack search
3:40 Search without page refresh
4:50 Remove submit button
5:40 Pagination with pagy
7:25 Infinite pagination
10:40 Stop endless pagination loop
11:35 Fix search
13:40 Query security
16:00 Highlight search results
17:05 Summary

Sign in to join the conversation