Turbo Streaming is going to work best with ActiveRecord Models. The Hacker News model uses Item models, which can be stories, comments, jobs, polls, or poll options. In the first implementation, the Item was modeled to be as generic as the API dispensed. This time, stories and jobs will continue to be modeled as ItemContinue reading “Turbo Streaming Top Items – HOTWire HNPWA #2”
Category Archives: ruby on rails
HOTWire HNPWA #1: Setting up for Top Stories
Follow along as we build the HOTWire Hacker News Progressive Webapp, or HHNPWA. This will build on the lessons from the Hacker News Progressive Web App, and will leverage all the enhancements that come from Turbo. In the end, you can compare the two, and decide for yourself what works.
Protecting ActiveStorage Uploads
ActiveStorage is a great addition to Rails. However, if need to protect uploads through a means more secure than the security by obscurity provided by the redirect service, you need to write your own controller. Setup a demo If you don’t have an existing app using Rails 6.1, you can follow these steps. Otherwise skipContinue reading “Protecting ActiveStorage Uploads”
Updated Tutorial: How Do I Drag and Drop Items in a List?
How do you configure a more complicated Stimulus controller that manages dragging items around in a list? Let’s start with our simple ordered Todo table in html: The todo order comes from a priority associated with each item, so that we’ll be able to keep track of which item needs to be moved. We alsoContinue reading “Updated Tutorial: How Do I Drag and Drop Items in a List?”
Display your Progressive Web App’s Offline Ability
Your progressive web app works offline, but do your users know that? You can use a Stimulus controller to manage your service worker, show the caching status, and hint to your user that the webpage will work offline.
Introducing Mailbox Tester
Do you send lots of emails with your Rails app, and wish you had a way to spot check them? Fix those typos, and make sure the dynamic content looks correct? It’s easy to verify there are no code bugs with Rail’s builtin Mailer preview. But how do you prevent sending someone’s wrong order orContinue reading “Introducing Mailbox Tester”
Testing Tables in ActionText Using System Test
So you’ve built a fascinating, interactive addition to your ActionText page. How do you test that interactivity? You can use System Test, a feature built into Rails to run apps and test them in a web browser. This simulates real usage, especially since the browser supports CSS and Javascript. Since the Rich Text Tables tutorialContinue reading “Testing Tables in ActionText Using System Test”
Adding Tables to ActionText With Stimulus.js
First, I’d like to thank Chris Oliver for his wonderful Railsconf 2020.2 talk, Advanced ActionText: Attaching any model in rich text. I’d highly recommend you watching that first for context, as I’m going to implement this ActionText table based on his Youtube preview. Towards the end of the video, Chris mentions you could use theContinue reading “Adding Tables to ActionText With Stimulus.js”
Radio Selection Unselect with Stimulus.js
Radio buttons, modeled after physical buttons on old radios, allow for only one element in a list to be selected. The browser automatically unselects the other options. This simple behavior often fits your needs, but I recently found myself wanting to be alerted on an unselect action so that I could change what was displayedContinue reading “Radio Selection Unselect with Stimulus.js”
Using CSS in Rails 6
I’ve been finally moving some of my Rails applications from Rails 5.2 to Rails 6 and I always seem to get caught up on the webpacker CSS locations. It’s not uncommon to spend a lot of time figuring out where the CSS went, and why it’s not being served. Pre-webpacker, there were two sprockets directivesContinue reading “Using CSS in Rails 6”