Hotwiring Rails - April 2022

#4・
652

subscribers

6

issues

Subscribe to our newsletter

By subscribing, you agree with Revue’s Terms of Service and Privacy Policy and understand that Hotwiring Rails will receive your email address.

Hotwiring Rails - April 2022
By David Colby • Issue #4 • View online
Hi folks — Welcome to the April 2022 edition of Hotwiring Rails!
The Rails 7 content rush has slowed down, giving us a bit more time to breath and digest all the new tools, which is probably for the best.
This month we’ve got a series on distributed systems in Rails, a wonderful, code-free article on when to use ViewComponent, and a thorough look at import maps in Rails. Plus other great articles and interesting new PRs and releases in Rails-land and a job opening at a great company.
Thoughts or feedback on how I can make this newsletter more valuable? Have something to include in next month’s edition? Reply to this email, or find me on Twitter.
- David

Articles and guides
Distributed Systems In Rails series by Nate Hopkins
This three part series is a super valuable and practical guide to thinking about and structuring distributed systems with Rails. Part one of the series is theoretical, parts two and three offer practical approaches to configuring Sidekiq and database connections properly in production.
The Problem That ViewComponent Solves For Me by Jason Swett
I’ve spent time exploring ViewComponent before, but I’ve always struggled to articulate exactly when I should reach for a component — my brain usually just defaults to helpers and then one day I wake up to a mess of helpers.
In this piece, Jason shares his thought process on why he reaches for ViewComponent in a way that helped me reason more clearly about my own code. No code examples in this one, just thoughts.
Hotwire Handbook Part 1 by Phil Reynolds
This article is a series of small, well-explained features implemented with Turbo Streams.
While the official documentation lags behind, these types of practical, code-heavy demos are the best way for new folks to get started.
Import Maps Under The Hood In Rails 7 by Paweł Dąbrowski
Like many of the new front-end tools released with Rails 7, importmap-rails is not very well documented. This article from Paweł is a thorough look at what import maps are, how they work, and how to use them in your Rails application.
Import maps are not right for every use case, but if you want to explore, this is a great starting starting point.
Dynamically Re-use and Lazy-load Pages Using Hotwire
This article describes an interesting technique from the Avo team to re-use views across the application, with a healthy dose of Turbo Frames in the mix. The use case here is a bit niche, but the technique is neat.
A job opening for Rails devs
CareerPlug is looking for a Senior Software Engineer to join their remote team. I worked with this team for a very long time, and can personally vouch for the kindness and talent of the folks that work here. If you are a senior-level Rails developer based in the US, you won’t find a better place to learn and grow.
Bonus: If you get the job you might get to discover some of my old, badly written code.
New and interesting Rails-land PRs and releases
The first Ruby 3.2 preview is out and the headline feature is WASM support. Smart and cool folks will undoubtedly find fun ways to use it, once they’ve had time to explore.
CableReady and StimulusReflex both got new pre-release versions, inching closer to major version bumps that have been in the works for many months. The highlight in both new pre-releases is shipping the package’s JavaScript along with the Ruby gem, making it much easier to use CableReady and StimulusReflex with importmap-rails.
In Turbo-land, a proposal to add a new Stream actions for adding and removing classes from elements has been open since late February — the PR addresses a big limitation of Turbo Streams. Given the philosophy of the project, I will be surprised if this proposal is accepted, but if it is it will be a nice upgrade.
More likely to be accepted is a PR adding support for preloading content with Turbo, improving on limitations of the native `rel=prefetch` behavior which can be tricky to use for dynamic content.
Finally, an important Turbo bug fix PR was opened, and hopefully will be merged soon. The bug fixed by this PR can be a blocker for migrating cleanly to Turbo, and the double `turbo:load` event firing can cause all sorts of hard to diagnose problems.
Recent articles from my blog
Toggling view layouts with Kredis, Turbo Frames, and Rails is a quick look at using the very fun Kredis gem to implement a common UX element.
User notifications with Rails, Noticed, and Hotwire offers a quick introduction to Noticed, and demonstrates using Noticed and Turbo Streams to build real-time in-app notifications with minimal effort.
Finally, if you sometimes read about non-Rails topics, I wrote a piece describing the process of writing and publishing my book on Gumroad and the results of the launch. I find this type of in-the-weeds look at processes that are often very opaque to be interesting to read, so I was glad to get to write something that might be helpful to the 8 other people
Until next time
This newsletter went out to ~420 folks today. If you enjoyed it, I would love for you to share this newsletter, and the link to subscribe, with your friends and colleagues who might find it interesting.
Did you enjoy this issue?
David Colby

Hotwiring Rails is a once-monthly newsletter curating the latest content on Rails, Hotwire, and other things you might find interesting.

In order to unsubscribe, click here.
If you were forwarded this newsletter and you like it, you can subscribe here.
Powered by Revue
Colby Consulting, 13359 N Hwy 183 #406-1058, Austin, TX, 78750