You probably needed to split a full name into first and last name at some point. How would you split the string Ayrton Senna da Silva into Ayrton as the first name and Senna da Silva as the last name? What if the name contains inconsistent amounts of whitespace in between the words? Eg: Ayrton Senna da Silva . "Ayrton Senna da Silva" . split ( " " ) # => ["Ayrton", "Senna", "da", "Silva"]…
I've recently discovered (or at least found a good use case for it) the satisfy matcher in RSpec. My intention was to ensure an attribute contained a string and not another string (within have_attributes ). I tried a few variations of the code below, but none of them worked: message = Message . first expect ( message ). to have_attributes ( conversation_id: conversation . id , customer:…
Rails 8.1.0 (released on October 22, 2025) brings a new feature that allows you to open the file that caused the error in your favorite editor. To enable this feature, you need to set either EDITOR or RAILS_EDITOR environment variable with the path to your editor, for example: # .bashrc / .zshrc export RAILS_EDITOR = "cursor" Then, when you are taken to the error page, click on the pencil icon to…
Have you ever needed to know if a record in Rails was just created — especially after using create_or_find_by or find_or_create_by ? Most Rails devs reach for new_record? , but it won’t help after create_or_find_by , because the record is already saved. So how do you know if a record was just created? Say hello to previously_new_record? , which for my surprise is available since Rails 6.1 . It…
Rails 8 got even better for developers who love clean CLI workflows. You can now customize the command-line tool used by rails dbconsole with the new config.active_record.database_cli setting. Prefer pgcli over the default psql to connect to your database? Make your dev experience smoother with autocomplete and syntax highlighting: # config/initializers/database_cli.rb Rails . application .…
This is the third post of the series "Migrating From Dokku to Kamal" and today I am gonna show you how I've set cron with Kamal , click here to read the second post of the series in case you've missed it. I needed a way run periodic tasks on Kamal to replace Dokku's scheduled cron tasks . Cron seemed the way to go according to this pull request on the Kamal repo, but making it work turned out to…
This is the second post of the series "Migrating From Dokku to Kamal" and today I am gonna show you how I've set up my servers with Kamal , click here to read the first post of the series in case you've missed it. The author assumes you've a basic understanding of how Kamal works, you can familiarize yourself by checking the official documentation . Below you can find part of my final deploy.yml :…
I have a 2 GB Memory, 1 vCPU, 50 GB Disk VPS on Digital Ocean which cost me 12 USD per month. Comparing the prices with Hetzner I noticed I could have 3x 4 GB, 2 vCPU Arm64, 40 GB Disk for 13.53 EUR per month. That's a lot more power for almost the same price. The droplet is running a Rails application with Dokku . I really enjoyed my time with Dokku, it makes our lives so much easier when setting…
Problem You got a Rails app with Turbo Drive and some charts powered by ECharts . It works fine until you navigate to another page and hit the back button. When navigating back in the browser history, somehow Turbo can't deal with the charts and displays an empty square instead of rendering them. Only a full page refresh can make them appear again. The Lazy Solution The simpler (but not so nice)…
I struggled to build and install Python on M1. Only got this error configure: error: Unexpected output of 'arch' on OSX . I had Homebrew and asdf installed for arm64 (default Apple Silicon / M1 architecture). That's what worked for me: duplicate iTerm (Finder -> Applications -> Right click on iTerm -> Duplicate) and set it to run with Rosetta (Right click on the duplicated iTerm -> Get Info ->…