Blog
Fixing page jump in Rails websites using Turbo
This was a very annoying problem that had a straightforward fix but was hard to track down.
You have a Rails website using Hotwire/Turbo that is, after clicking a link, skipping to the top before navigating to the requested page. The steps needed to replicate are:
- Scroll to the bottom of the current page
- Click a lin...
Regex match for spaces outside of HTML tags
:::{info} This turns out to be quite a tricky problem to solve. The solution below is meh. I have since stumbled across a fantastic gem called Truncato that handles these situations beautifully. :::
Let’s say you are truncating a blog post to produce an excerpt for multiple posts in an index view. In Ruby on Rails, we...
How to prepare Rails assets before running tests
I’m currently building a Rails 7 app that was started with rails new myapp --css=bootstrap
. This means Rails set up my app to use esbuild to compile all my CSS and JavaScript assets. This new --css
flag provided by Rails is a fantastic improvement over previous implementations like Webpacker. Now we can just run bin/de...
How to exclude ID lookup by integer when using FriendlyId
Hello there! Are you at the point in your Ruby on Rails project where you’d like integer-based slugs like /users/2
to be friendlier and look like /users/matt
instead? How about /posts/how-to-make-great-tacos
instead of /posts/31
? There are many reasons you’d want to do something like this, and there’s a great gem calle...
Pinched nerve
My creative drive is writing checks my body can’t cash. It has come to my attention that, as an Elder Millenial, I can’t combine new office equipment with increased hours working and expect to walk away unscathed. Multiplying the directional change in my gaze by the number of hours at my desk has resulted in a pinched ...
Using Clearance with Rails 7
For some time now, the Ruby on Rails community has anointed Devise as its preferred authentication solution. I’ve repeatedly used Devise, and it’s great. Not all of us have the time or expertise to roll our own auth, so it’s fantastic a solution exists that is widely adopted. It was only natural that I’d reach for Devi...
My new system
I’ve been starting my weekdays at 4:00 am for the last seven weeks. It’s dark, and the sound of silence is all around. I made the change to my morning routine “cold turkey” and haven’t missed a day. I am typically in bed before 9:00 pm and asleep shortly after. I’m shooting for seven hours of sleep a night, even though...
Apple Studio Displays
Thanks to ordering the VESA mount option, I’m too late to the party to do a spec review, but I want to address the mood in the room. The internet sure went on a hot take rampage with these displays, didn’t they? There was a lot of disappointment and exasperation flying around. Here’s why I think a lot of the frustratio...
I cancelled my Hey email accounts
Yesterday I canceled two @heyhey email accounts. It’s really hard to figure out what the two fellas at the top were thinking by implementing their new company policy on political/social discussions. It’s especially bizarre given the outspoken nature of both the founders.
Unfortunately, it’s becoming apparent today tha...
Dealing with Unity versions
I recently got a MacBook Air to serve as a mobile-friendly companion to my iMac and it got me thinking about how to deal with Unity installs. I had primarily been working on a single machine without any team members to worry about. Therefore my one machine, and the Unity versions on it, were all that mattered. But as I...
Blog Categories
About These Posts
My blog primarily contains writings about my work on computers, but I occasionally mix in fun life stuff. I am, at best, a mediocre writer, but I like doing my part to give back to the community. Feel free to contact me if you have specific something to chat about. See you around!