Let's Build with Hotwire and Rails - Quick Data Filtering

Let's Build with Hotwire and Rails - Quick Data Filtering

Welcome to another edition of my Hotwire and Rails series, where I take you through a journey of creating old conventions that used to require JavaScript and bringing them to life using Hotwire and Rails.

This guide is a simple one aimed at showing foundational principles for using Hotwire. We'll build a simple database of quotes from the movie Dumb and Dumber and present simple filters to cycle through that data.

The filters toggle the order of different types of data related to a Quote model and then, upon click, will instantly sort themselves in ascending or descending fashion.

It's important to note that this functionality is completely possible with legacy Rails applications. Still, the main difference lies in the request cycle when a user might click a sortable link.

Additionally, we can now embed forms that render in place to edit specific quotes on the fly.

Hotwire brings us a lot of power which is very exciting to see as you begin to construct applications that used to take loads of JavaScript, JSON, and third-party libraries to get the job done.