For the three-day holiday weekend I was fortunate to enjoy these epic views in Big Sur. When I returned to civilization on Tuesday, I went heads-down and focused on the Hotwire unit, trying not to get distracted by Rails World announcements. I almost succeeded!
Hotwire isn’t well documented
Despite having a dedicated website, Hotwire isn’t that well documented. If you search for “Rails” on the Hotwire website, you’ll have a hard time finding anything. It’s also not mentioned in the Rails Guides.
What does that mean? I spent a lot more time reading source code and documentation this week and had to resist the urge to rewrite the whole thing. 🤣
Dive into the docs and make something awesome
The good news is I was able to show some interesting patterns, such as broadcasting a Phlex component from anywhere like this:
# The new way! 😊
Components::Account::Dashboard.new(account).broadcast_replace
See how there’s no ID or “streamable” required? Compare that to how people do it today with partials, etc.
# The old way! 😬
Turbo::StreamsChannel.broadcast_replace_to "account_#{account.id}",
partial: "accounts/dashboard",
locals: { account: account }
Course content updates
I adjusted the format and, of course, added some new content.
Phlex and Hotwire
I accomplished a ton this week, including a bunch of videos on Stimulus, Turbo Frames, Streams, and Broadcasts. You’ll find some handy patterns in the videos that show how you can better organize Stimulus and Turbo throughout your project.
I focused on converting existing ERB and Stimulus controllers into components, then extracting them into more basic components, and finally implementing them back into existing ERB, since I’m assuming most people are using this in existing Rails applications with lots of ERB templates.
The Espresso Standard ☕️
I got some excellent feedback from a customer who pre-ordered the course:
I think the episode could be split around the 8-minute mark. The second part is all about rendering partials from Phlex, which sounds like its own subtopic. Fine either way, but since I’m usually watching video tutorials while enjoying an espresso, it’s nice to have them under 10 min at a time.
This is now my new standard, and I absolutely love the imagery of somebody enjoying a cup of coffee while spending 10 minutes each day learning something new. From the Build forms with components unit on, you’ll notice that I try to keep my videos below 10 minutes.
Rails World distraction: A Tour of ActiveRecord Tenanted
To go on a bit of a tangent, I did get nerd sniped this week by the Rails World ActiveRecord Tenanted gem and dove into the source code for a sound check.
It has nothing to do with Phlex or this course, but it does have a lot to do with giving each customer in a Rails application their very own SQLite database.
What’s next?
I’m not gonna lie: the Phlex and Hotwire unit was the one I dreaded the most, mainly because I’m not a fan of how Turbo Frames, Streams, and Broadcasts are so brittle due to their reliance on DOM IDs to get anything done, but I feel pretty good about the abstractions I made and the steps I showed on video on how to get there.
I finished that on Friday afternoon and started to take my Turbo Pagemorphs victory lap, but ran into some issues with the layout that I’ll have to fix next week. That means the Phlex and Hotwire unit should be done next week and I’ll start working on “Styling with CSS & utility frameworks”.