Rails

JWT Storage in Rails + React The Right Way

Local or session storage in the browser might feel like the right place to store a JWT [https://jwt.io/] when authenticating your client-side app against a backend API. Maybe it feels like the right place because I told you to do that. But its not right! Its wrong and…

Composable Query Builders in Rails with Arel

We'll use Arel to build a flexible query builder class that will allow us to dynamically search our database given any search form input. This post focuses less on building intricate Arel queries and more on enacting a design pattern that allows us to leverage Arel in a…

DIY Google reCAPTCHA with Ruby

reCAPTCHA is an anti-bot tool you can implement in your web app to prevent bad actors from programmatically filling out forms and spamming your endpoints. In this post, we'll implement Google's reCAPTCHA protocol using the Google reCAPTCHA 2 client-side library and our very own hand-rolled verification…

Building a Custom Logger with Active Support Tagged Logging

The ActiveSupport::Logger class is the go-to logging tool for Rails––the default Rails logger represents an instance of this class. Active Support provides some additional flexible logging classes that we can use to customize logging functionality in our Rails app. The default logger allows us to set logging levels,…

Smarter Rails Services with Active Record Modules

MVC is Not Enough! We're familiar with the MVC (Model-View-Controller) pattern that Rails offers us––our models map to database tables and wrap our data in objects; controllers receive requests for data and serve up data to the views; views present the data. A common analogy is that…