Hotwiring Rails Newsletter - December 2021

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. If you’d like to get the next edition of this (monthly) newletter in your inbox, you can subscribe here.

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

Rails, Hotwire, CableReady, and StimulusReflex are BFFs by Nate Hopkins

This article from the creator of CableReady and StimulusReflex offers perspective on how the different pieces of the modern Rails landscape fit together.

This one is full of useful links and thoughtfully lays out a key philosophical distinction between Turbo’s aggressive adherence to RESTful principles and SR’s embrace of flexibility.

Read it on dev.to

Kubing Rails: stressless Kubernetes deployments with Kuby by Vladimir Dementyev and Travis Turner

If you (like me) have been intimidated by the complexity of Kubernetes, you might be interested in taking Kuby for a spin.

In this detailed tutorial on deploying a real Rails application with Kuby, the Evil Martians team gets down in the weeds and describes challenges they encountered and how they overcame them while deploying a Rails + AnyCable application to DigitalOcean with Kuby.

Read it on evilmartians.com

Why Hotwire in 2021 by Cédric Fabianski and Elizabeth Braae

The Bearer team talks about their transition from a complex React-powered frontend to a simplified, Hotwire-powered approach with a small team and a rapidly growing product.

If you’re considering whether your team can make the switch, I’ll leave this quote from the article here, click through to read the rest:

“We were essentially maintaining two applications where one should have been enough. The big learning was that this architecture might have made sense for large, stable applications, but it didn’t make sense for a company iterating fast to find a good product market fit.”

Read it on bearer.com

Building a Real-Time Chat App in Rails Using ActionCable and Turbo by Abiodun Ajibade

This implementation of the classic chat application demo relies on Turbo Streams to build a multi-room chat application, with a little bit of Stimulus in the mix. Turbo Stream model broadcasts keep things simple and clean — a nice introduction to the power of Turbo Streams and, more generally, the power that ActionCable unlocks for Rails libraries.

Read it on honeybadger.io

Rails Remote Elements Tutorial by Steve Polito

Steve takes us through an interesting approach to implementing a SPA with rails-ujs and Stimulus, showing us that the tools to build highly responsive user experiences in Rails have been available for years.

Leveraging Stimulus data attributes and built in rails-ujs events, we get a classic SPA todo application without React. An interesting experiment and learning experience, and a nice reminder of the power of rails-ujs, forgotten, but not gone.

Read it on stevepolito.design

A Rails Multi-Tenant Strategy That’s ~30 Lines and “Just Works” by Jason Meller

This quick read demonstrates a simple multi-tenant implementation without reliance on gems. Thoughtfully designed and battle tested in a large production application, this is a nice implementation of a common requirement for Rails-powered SaaS applications.

Included is a neat trick for setting Current in the Rails console, discussions of testing considerations, and a thoughtful acknowledgement of criticisms of Rails’ Current attributes implementation.

Read it on dev.to

Rails 7, Railties, and Sorbet at Shopify with Rafael França from Rails Core by Remote Ruby

I’ll confess that I’m not much for listening to technical podcasts, but this conversation between the Remote Ruby team and Rafael França was very enjoyable.

Come for the (now confirmed) hint at the Rails 7 release timeline, stay for the thoughtful words from Rafael on Shopify’s development practices, types, and Hotwire.

Listen on transistor.fm

The CableReady Language Implementation Project

The StimulusReflex team has a vision to expand CableReady outside of the Rails world and into a “universal standard tool for developers to dynamically control browsers from the server”. This is a big project, and they’re looking for help from developers capable of building server-side libraries in languages like Go, Python, and Java. If this sounds like you, give their call for support a review and get in touch with the team.

Read it on dev.to


New and interesting PRs and releases

Turbo

Turbo 7.1 is out!

This is a huge release that includes changes that adds rails-ujs style functionality to Turbo and fixes for a number of outstanding bugs, a few of the highlights in this release for me:

  • Push state history on frame navigations — This is the most exciting addition in 7.1 in my opinion, making it trivial to update URLs on frame navigation. This change dramatically improves the usability of tabbed interfaces and search forms powered by Turbo Frames
  • Add requestSubmit polyfill — This small change eliminates the need to manually add the requestSubmit polyfill to projects using Turbo. If you’ve moved away from rails-ujs, you may have gotten bit by the lack of access to Rails.fire(‘submit’) like me. requestSubmit with this polyfill is a nice alternative
  • Add data-confirm behavior to Turbo — Another rails-ujs behavior cleanly migrated to Turbo. The implementation is slightly more verbose so that it doesn’t clash with existing rails-ujs behavior, just in case your project has Turbo alongside old rails-ujs code.

Rails

Rails 7 RC1 is out!

With this release, we’re on track to see Rails 7.0 out before the end of the year.

Since Alpha 2 in September, much of the work has been on bug fixes, deprecation, and documentation. One interesting PR that made the cut was the addition of a standardized error reporting interface, via Rails.error that should simplify handling and reporting errors in Rails apps.


Recent pieces from my blog

I won’t be publishing many brand new pieces for the next few months because I’m focused on finishing my modern Rails development book/course (~2/3 done with the code).

Before going heads down, I published this quick piece on my Rails + esbuild config for live reloads.

I’m also committed to keeping my turbo-rails documentation pieces up to date with new Turbo releases — Turbo Frames on Rails was updated after the release of Turbo 7.1.

Expect to see many more shorter form tutorials from me after I publish my Hotwiring Rails course in (fingers crossed) late January. ___

The best things I read recently

The unreasonable effectiveness of simple HTML by Terence Eden — This newsletter, and all of my writing, is about modern web development. I’m interested in building highly interactive websites, which some times means using techniques absolutely will not work on Internet Explorer, much less on a PSP or a TV.

This piece from January of 2021 is a thoughtful reminder that, for many use cases, your users are best served with simple, old school websites that work, all the time, in every situation, with no fluff.

Exploring new things is fun, cool, and sometimes profitable, but if you’re building web sites for critical services, very broad audiences, or vulnerable populations, you probably don’t need that slick animation or cool new JavaScript tech.

The pragmatic engineer test: 12 questions on engineering culture by Gergely Orosz — Hiring Rails developers seems to get harder by the day and retaining your current team can be a challenge.

Building the right culture — and sharing that culture widely — can help you get a leg up. Gergely’s thoughtful overview of the questions you should be able to answer as a leader about your engineering team’s culture is a nice place to get started.

Bonus — Jamie Lawrence walks through how his team at Podia scores on these 12 questions.

Until next time

RailsConf 2022 has been announced. I’ll be there — I hope to see some of you there too!

That’s all for this month’s edition of Hotwiring Rails. For those of you who celebrate, happy holidays! I’ll be back in the new year.

Subscribe to Hotwiring Rails

Enter your email to subscribe to a once-monthly newsletter curating the latest content on Rails, Hotwire, and other things you might find interesting.