Hotwiring Rails Newsletter - January 2022
01 Feb 2022This 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.
Thoughts or feedback on how I can make this newsletter more valuable? Have something you’d like to include in next month’s edition? Send me an email, or find me on Twitter.
Table of contents
Articles and guides
The Hotwire example treasure trove by Sean Doyle
This Github repo has been making the Twitter and Discord rounds lately, and for good reason.
Each branch in the repo contains a writeup and full implementation of a common UX pattern built with Stimulus and Turbo. Keep this handy and reference the examples when you need them.
View the treasure trove on Github
Live reloading for Hotwire Rails apps by Kirill Platonov
With the demise of Webpacker (more on that below), replacing webpack-dev-server is top of mind for many folks. Kirill explored this problem and built a gem to tackle it.
Read the how-to on kirillplatonov.com
Remote modals with Rails, Hotwire, and Bootstrap by Benito Serna
This quick article offers a slightly different take on implementing server-rendered modal content with Turbo, hooking into the before-render callback to neatly transition the modal out when needed.
Read the full article on bhserna.com
Pagination in Rails from scratch by Ana Nunes da Silva
Implementing common application needs from scratch can be a really interesting learning exercise. It can be worth doing even if just to get more comfortable reasoning about the problem before reaching for a battle-tested gem.
In this article, you’ll build a simple pagination system from scratch, complete with a front end implementation and the standard set of convenience methods.
Build your own pagination on ananunesdasilva.com
Speaking of building things from scratch, ICYMI, Steve Polito’s recent look at building an authentication system from scratch is a good read.
Dueling tutorials: Two ways to lazy load tooltips with modern Rails
Steve Polito published “Hotwire: Asynchronously loaded tooltips” last week based on code from Sean Doyle. This is a well-constructed article guiding you through remotely loaded tooltips powered by Turbo Frames. As a bonus, it includes a nice use of TailwindCSS’s peer class.
Julian Rubisch read Steve’s article and was inspired to write up an alternative implementation of the same functionality with Futurism. As Julian notes in the article, Futurism can offer a simpler migration path for legacy applications that were not designed from zero with Turbo Frames in mind.
Sometimes we can get stuck in one single path forward — Julian’s response article is a great reminder that there are usually alternatives out there when we need them.
On Stimulus Reflex: Why and Why by Stephen Margheim
This is a thoughtful, code-free read from Stephen. Inspired by conversations on the StimulusReflex Discord, Stephen presents a take on how StimulusReflex fits into a Turbo-powered Rails world.
Rails 7 features, before and after by Zakaria Fatahi
This gist is a nice, compact introduction to some of the most interesting new features in Rails 7. A nice bookmark to read when you’re making the Rails 7 upgrade.
New and interesting PRs and releases
Farewell, Webpacker
Webpacker was officially retired in January. Sadly, it was retired before an official release of Webpacker 6 was cut.
Rails 7’s import maps and js/cssbundling gems made Webpacker’s retirement a foregone conclusion, but it was surprising to see it retired without a 6.0 release.
For folks on Webpacker 5.4, despite the retirement I do not think there is an urgent need to switch off of Webpacker — you can still upgrade existing apps to Rails 7 without changing bundling strategies.
For folks who love Webpacker and want to stick with it long term, Webpacker’s development has moved to Shakapacker, which is likely to be maintained well into the future.
Custom Turbo Stream actions
This is technically a comment on a PR, but its my newsletter and I make the rules. Sean Doyle stars again, this time demonstrating a method for “adding” new actions to Turbo Streams through clever use template tags and Stimulus.
If you need more power than Turbo Streams seven actions offer (and you can’t use CableReady), this technique might help.
The best things I read recently
This is the third Hotwiring Rails newsletter I’ve written, and Baldur’s writing has been in the best thing(s) I’ve read recently twice.
Apologies for the lack of variety but this piece was a great read on why keeping up with the latest and greatest in web development can feel so overwhelming compared to the same problem in other fields. Baldur’s article is well-worth reading for anyone feeling overwhelmed by trying to keep up with all the newest tools, tricks, and techniques in web development.
In particular, shifting from “keeping up” to doing research is a great mental model for cutting through the noise and keeping yourself focused on resources that are useful for you and interesting to you. This specific article is a funny thing to share in a newsletter about the latest Rails developments — the whole deal is that I share a bunch of Rails-related content because who doesn’t love learning as much as possible all of the time, right?
Putting the article into context with this newsletter: I resonate with Baldur’s “do research” approach and I model my own content consumption in a similar way.
In Baldur’s terms, my “Work Question” is what’s happening at the edge of Ruby on Rails. Most of the content I consume is only useful to me in that context, and that’s where I keep my brain while I’m reading. Before organizing myself around this Work Question, I spent a lot of time trying to keep up with React and Vue, and I spent hours following tutorials on building serverless apps (yikes) — things I had no real interest in or need for, but that seemed like I should be aware of.
One day I just stopped reading all of that stuff. I have no idea what’s going on with React, or Vue, or even if those are still the cool JavaScript frameworks to use. Instead, I just learn about what’s going on in Rails, and I’m happier and better informed because of it.
If you are deep in information overload, read Baldur’s piece for help and then apply his approach to this newsletter — if an article I linked doesn’t fit your Work Question, do you need to read it or can you ignore it?
Read it on baldurbjarnason.com
Until next time
RailsConf 2022’s Call For Proposals is open — you have until February 28th to submit!
Thanks for reading! Tune in next month for news on Hotwired ATS.