Skip to main content

Category: Shorts

Quick Tip: Reading Ruby Version from .tool-versions in Your Gemfile

While migrating from asdf to mise as my version manager, I needed to update how my Gemfiles read the Ruby version. It’s a small change, but I thought it might be useful to share.

With asdf, I was using .ruby-version:

ruby File.read(File.expand_path('.ruby-version', __dir__)).chomp

Now with mise using .tool-versions, which can contain versions for multiple languages, the line changed to:

ruby File.read(File.expand_path(".tool-versions"))[/^ruby[@ ](.+)$/, 1]

The regex matches a line starting with “ruby” (followed by either a space or @ symbol) and captures the version number.

A Simple Fix for Dynamicly Added External Widgets in Turbo-Enabled Sites

While working on Humadroid, I recently stumbled upon an interesting challenge with our chat widget. It’s a small discovery, but one that might save other developers some headaches.

The Problem

If you’re using Turbo (formerly Turbolinks) and external widgets like Chatwoot, you might notice they disappear or reload whenever you navigate between pages. This happens because these widgets usually attach themselves to the end of your DOM, and Turbo replaces all that content during page transitions.