Hotwiring Rails Newsletter - March 202202 Mar 2022
This newsletter went out via email to the Hotwiring Rails subscriber list, but I know that not everyone wants another email cluttering up their inbox. For those folks, I’ll always publish the full content of the newletter here too, so you can get all the content with none of the emails.
Table of contents
- Articles and guides
- New and interesting PRs and releases
- My recent writing
- The best things I read recently
Articles and guides
Stripe checkout and customer portal Ruby on Rails Tutorial by Andy Leverenz
Building payment infrastructure is always challenging. This in-depth tutorial and accompanying screencast, if video is your thing, is an excellent resource for quickly integrating Stripe into your application.
I love long, detailed tutorials, and this one checks all the boxes. If you need to get Stripe checkout setup and aren’t sure where to start, this is the place.
The In-depth Guide to ActiveRecord load_async in Rails 7 by Paweł Urbanek
Paweł’s article on the load_async ActiveRecord feature added in Rails 7 is an exceptionally detailed look at how load_async works, its potential dangers, and the right way to approach using load_async in your Rails applications.
Highly recommended for anyone working on production Rails apps to keep one around as a resource.
Exploring Trix by Konnor Rogers
This in-progress series explores techniques for extending and enhancing the functionality of Trix. Trix’s integration with Rails is really convenient, but the limitations of the editor have made it hard to adopt for many use cases. Konnor’s work in this series makes Trix more valuable.
Hotrails.dev by Alexandre Rubin
This is very much worth the time for folks new to turbo-rails.
Toggling page content with Turbo Frames and Kredis by Peter Phillips
I love Kredis, and I am excited for more folks to start creating cool stuff with it. In this quick tutorial, you’ll learn how to combine Kredis and Turbo Frames to toggle the visibility of page content, and to persist that preference across page loads.
This is a great introduction to Kredis, and the types of problems that Kredis can help you solve.
Global presence by overstimulated
This is a really neat demonstration of a multi-region application built on fly.io, exploring this extremely complex question: “what does it look like to hook up a system of live-DOM-updates-over-Websockets to a caching layer that’s distributed across multiple regions?”
The end result is a really neat example of some of the problem spaces that are now accessible to determined Rails developers.
Building a Lightbox with Hotwire and Swiper.js by Julian Rubisch
Julian’s take on adding a simple lightbox to a Rails application is a great resource, approachable for all levels of Rails developers and the step-by-step approach makes it accessible even if you are new to Turbo and Stimulus.
This is a great one to bookmark for the next time you need to add a lightbox to a Rails application you maintain :)
Modern Front End Magic With Rails 7: A Visual Editor for Markdown by KUY.io
This series released in October 2021 but I first came across it this month and found it to be an exceptionally thoughtful and detailed look at solving a hard problem with Rails and Hotwire.
The two part series walks through building a WYSIWYG markdown editor from scratch in a Rails application with plenty of Turbo and Stimulus in the mix.
Load More Pagination in Rails with Hotwire Turbo Streams by Dale Zak
Everyone needs to paginate resources — Dale Zak has a great, quick write up on building pagination from scratch with Turbo and Stimulus.
This article includes a really neat way to send Turbo Stream GET requests with a small Stimulus controller to modify headers — a handy trick to have in your Turbo bag.
New and interesting PRs and releases
Last month, I linked to Steve Polito’s write up on building a Rails authentication system from scratch. A few weeks ago, Steve released an authentication generator for Rails 7 applications that allows anyone to add a simple authentication system to their Rails application.
The generator-based approach makes it easier to wrap your head around what your authentication system is doing, and to extend and modify it as needed.
Lázaro Nixon released a similar generator-based approach this month too.
I would still choose Devise for most commercial applications today, but the movement towards a more Rails-native approach to scalable, secure authentication is exciting and continues to receive support from the Rails core team. The challenges of integrating Devise into Turbo-enabled applications are likely to drive even more interest here in the coming months.
An extremely comprehensive Hotwire Rails template
Georg Ledermann’s opinionated Hotwire Rails template is a great starting place for a new Rails 7 application. The template goes well beyond the standard configuration options you’ll find in most templates — you’ll find linting, testing, and deployment needs are fully covered here too.
My recent writing
I wrote a book!
I am very pleased to share that the book on modern Rails development that I have been working on since the fall is now “published”, which means a little bit of self-promotion in this edition of the newsletter, and a much more regular cadence of blogs in the coming months now that I’m not writing a book and building a web app to publish the book as something more useful than a PDF.
Real-time previews with Rails and StimulusReflex
My exploration of markdown editors that led to the wonderful series from KUY.io linked above started with putting together this introductory-level tutorial on using StimulusReflex to preview markdown content as the user types.
Pagination and infinite scrolling with Rails and the Hotwire stack
Dale Zak’s article on pagination linked above, and a conversation on the StimulusReflex discord, inspired this article that introduces another approach to both traditional pagination and infinite scrolling via a small Stimulus controller.
Turbo Rails 101: Build a todo app with Turbo
This one does what it says on the tin: It is a brand new, “what the hell is a Turbo Frame and why do I care”-level introduction to Turbo Frames and Turbo Streams aimed at alleviating a couple of common sticking points for new Turbo users.
The best things I read recently
Spam accounts in 2022 by Josh Beckman
This is a quick, interesting read on the tactics that spammers use to game search engines and drive affiliate sales (in the best cases) or steal identities and cash (in the worst cases).
If you have ever built an SaaS that gives customers access to post jobs, build a website, or otherwise create public-facing content that can be used to run a scam, you’ve probably dealt with tactics like this.
Server-Sent Events, WebSockets, and HTTP by Mark Notttingham
This piece was near the top of the dreaded orange site recently and I found it to be a really interesting read on the challenges of making pub/sub a standards-defined part of the web.
The work that goes into defining and expanding the standards that enables web developers to build incredibly complex experiences that work seamlessly across browsers and devices always leaves me feeling awed and slightly intimated. Writing like this that helps illuminate some of thinking that goes into how to solve these types of standards-defining problems is always a treat.
Until next time
If you’re a Rails developer who also happens to love filling out surveys, the folks at Planet Argon have a treat for you.
The link to apply for a RailsConf opportunity scholarship is open until March 11.