Ruby on Rails #157 Calendar Pagination with gem Pagy

21/01/2024 (3 months ago)
calendar pagination pagy

We are all used to pagination by clicking a prev or next page link.

But what if we could paginate by year/month/day?

Some time ago I asked Domizio Demichelis (@ddnexus), the creator of Pagy gem, this question. And it resulted in the creation of Pagy::Calendar!

Let's explore how we can add calendar pagination to our app and make it useable.

Episode source code:
Based on this blogpost:

0:00 Calendar pagination demo
02:20 Install Pagy Calendar
6:58 Tailwind styling
7:56 Paginate by year/month/week/day
11:08 Toggle calendar and normal pagination
12:58 Create an event for current date
17:04 Fix bug with max year being wrong
19:25 redirect back to page in calendar
22:11 link to Today

Sign in to join the conversation