Hotwire components that refresh themselves | Boring Rails: Skip the bullshit and ship fast

14-Jul-2025 13
Earlier this year, I made a quick tweet about a pattern that I think makes working with Hotwire apps much better. When you need to make a bit of UI that runs some code in the background, you can use turbo_streams to ‘refresh’ the front-end when the work starts, is in-progress, and finally when it’s finished. But the problem is that, out of the box, turbo_streams use partials. And frankly, it just kind of sucks to work with. I found myself annoying by having to match up dom_ids across files and passing in data as locals. And it’s hard to search the codebase for partials, leading to cases where you change a partial and break something elsewhere just because it wasn’t easy to find usage.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle