Image of Lucian Ghinda writing for notes.ghinda.com
Short posts mostly about Ruby and Ruby on Rails. You can find me at : Linkedin, Mastodon, Twitter, Bluesky or for longer posts at allaboutcoding.ghinda.com. Check goodenoughtesting.com if you want to learn to write fewer tests and cover more features. 
Subscribe via RSS here

In Ruby who's already there in main?

When you open a Ruby file who's already there?

puts self.inspect \# main
puts self.__id__ \# 16 
puts self.class.name \# Object

puts method(:inspect).owner.class \# Object

Why does inspect say main

This is a special case defined in the Ruby implementation:

CRuby source code

docs.ruby-lang.org is explicit about this behavior

Screenshot of Object\#to_s from docs.ruby-language.org

What other objects were instantiated before the main one? It seems only another one: Class

ObjectSpace used to show other objects instantiated before current one

Timeless articles about working with Time and Timezones in Ruby and Ruby on Rails

Here are two resources that I think are important to read when you are working with Time in Ruby.

It's About Time (Zones)

This article is a perfect base for understanding working with Time and timezones in Ruby and Ruby on Rails. 

I think the core idea of the article is always keeping in mind in Rails there are 3 timezones:
Source: It's About Time (Zones) by Elle Meredith
Scheduling events in user time zone

For this there are two articles that you should read: 

I will add here the main idea that I extracted from both of them but you should make sure to read them as they present more ideas and options and specific recommendations when scheduling events in user timezone.

  1. For recurring events that must run at a user's specific local time (e.g., "every day at 9:00 AM"), one option is to calculate and persist the event's hour relative to UTC (hour_in_utc). Another option is to use a library that knows how to compute the next occuring event and not do the calculation yourself.
  2. When considering timezones, please remember that time zones are data that change over time (due to reasons that could be social or political so future DST/rules can change), and you'll need to make sure that you sync your Timezone data. 
From Scheduling things in user's time zone by Julik Tarkhanov

How to create a new Rails app with Rails 8.1.0.beta1

How to create a new Rails app with Rails 8.1.0.beta1

gem install -v 8.1.0.beta1 rails

rails _8.1.0.beta1_ new mynewrails81app


You can also generate a new Rails app using the main branch. Rails has a long history of being used by major companies on the main branch, making it as safe as possible to run. While it's not an official release, any bugs that appear are likely to be resolved quickly.

rails new myrailsapp --main

Ruby Triathlon starts this week

The Ruby Triathlon starts this week! 

Rails World - Amsterdam, Netherlands, September 4–5

The first conference is Rails World happening in Amsterdam on 4 and 5 September. 

The tickets are sold out! So if you did not yet got your ticket, then make sure you keep an eye on it for next year :(

Rails World 2025

Friendly.rb - Bucharest, Romania, September 10–11

The next one Friendly.rb will happen next week in Bucharest, Romania on 10-11 September. Make sure you don't have plans for 12 September as we will have an outdoor day.

Tickets are still available at https://friendlyrb.com.

During the conference there will be a "Brew your own coffee corner" where you can bring your own pour overs and we will provide freshly roasted coffee beans from various roasters to delight your taste. There is also a The Friendly Gameshow a funny surprise that awaits for you part of the conference. And on Friday, we will have a Friendly trip to Sinaia, an easy outdoor trip to one of the most beautiful cities in Carpathian mountains.

Yes, I shared more details about this conference as I am one of the co-organisers - so feel free to ping me about it
I wrote 3 articles about why to join Friendly.rb this year: 

Friendly.rb conference
EuRuKo - Viana do Castelo, Portugal, September 18–19

The last one, three weeks from now, will happen in Viana do Castelo, Portugal  and it is the biggest Ruby conference in Europe: EuRuKo

Tickets are still available at https://2025.euruko.org and they have on Saturday a Ruby Safari - "Guided walking tour around Viana do Castelo, exploring local gems and hidden spots".

EuRuKo 2025

Flaky Tests, Courtesy of AI

When AI is writing tests in agentic mode, it's crucial to monitor its output. 

Sometimes, it uses tricks to pass the tests or creates unnecessary tests.

Diff from a change made by agentic LLM

For example, consider this diff that has at least two issues: 


1. The test is unnecessary for a medium-risk, medium-impact feature. It merely checks that the counter cache in Rails functions correctly. This test was written in an earlier iteration that I haven't reviewed yet to remove it. 

  1. The Category model has the following constraint:
index_categories_on_position_and_parent_id (position, parent_id) UNIQUE

Notice how it added a position: rand(1..1000) to make some tests to pass because they lacked the position?


This approach is just inviting flaky tests!

I added this to my Flakiness section: 

- Use consistent data across tests to avoid flakiness. Prefer existing fixtures instead of generating data randomly.
- Do not use `rand` or anything similar when generating data for tests.
- Use `travel_to` for all time-sensitive tests (assert time or need time to make the test work)
- Use `.sort` when the results are not guaranteed to be in a specific order.

Invisible work separates friction from flow.

Quote from Jony Ive about quality

No one will thank you for good error messages or default states, but they will feel it!
The difference between friction and flow is invisible work.

This is also true for the development process:

Sloppy names turn into messy objects and interfaces. Messy objects lead to slower teams.

The same goes for testing: Be careful about how you organise the code inside the test files because if it gets messy, it will slow down the development and debugging in the future.

It all compounds.

Details are never just details! If you are using AI to generate code, make sure it generates good names in your domain.

Remember to set the frequency for replication to Litestream!

Curious about how I ended up with an invoice nearing $100 for conducting over 20 million Class A operations on Cloudflare R2?

I initiated several Litestream processes across a variety of side projects and forgot to set the sync interval! :) It defaults to 1s

The backup I was handling was more complex than the main production database. It included slight variations in the SQLite file because it automatically queried various external services to check the status of different entities.

How to set sync-interval to litestream

Two new Ruby podcasts from Rails Foundation and Ruby Central

In case you missed this in the last period, there are two new podcasts in #Ruby world: 

On Rails - a podcast produced by the @Rails Foundation and hosted by @robbyrussell

👇

https://onrails.buzzsprout.com

https://onrails.buzzsprout.com

Ruby Gems Podcast produced by @rubycentralorg and hosted by David Hill and Marty Haught 

👇

https://www.buzzsprout.com/2509083

https://www.buzzsprout.com/2509083

PS: Both of them are hosted https://www.buzzsprout.com/ - built also with Ruby on Rails

Running all tests from the current branch

I enjoy creating small automations using Ruby and Bash. While it might be simpler to use Bash, I like #Ruby so much that I want to use it more.

Here are two examples of how to run all the tests that have changed in the current branch: an example for Minitest and one for RSpec

Don't let AIs rewrite your tests if once you agreed with them

Once you agreed to a set of tests: either written by you or written by AIs but guided by you, don't let the AIs to refactor/change the tests while they are trying to implement a feature. 

If your tests are there as specifications, then the implementation should be constrained by them. Therefore, they should not be changed unless you direct them to do so. 

A small tip for the about section of your own website

I am looking at various personal websites mostly focused on researching personal websites of technical people mostly programmers because I want to redo my own personal website - which is old and due for a redesign. 

And one thing that I noticed as a reader is that sometimes when I click on the about section the name is not written there. 

I will use my website as an example: 

website URL: ghinda.com 
the main page is the about: https://ghinda.com 

But if you read that page or use search you will notice that not even once I do write there my name: "Lucian Ghinda" 

Ruby San Francisco Scene is heating up

San Francisco Ruby scene is heating up

Source: https://sfruby.com


Already two events planned for this year:
1. SF Ruby AI Hackathon - 19 July - https://lu.ma/znhcct7v?tk=17VJ2z
2. San Francisco Ruby Conference - 19-20 November - https://sfruby.com

And of course let's not forget about Monthly Ruby Meetups -> https://lu.ma/sfrub, next one being on 4th June.

Huge props to Irina Nazarova and the team there. 
They are doing fantastic work to build up the Ruby scene in San Francisco!

Reminder to update Ruby 3.2 and Rails 7.1.x

This is your reminder that if you run #Ruby 3.2, now would be a good time to start planning an update.

It will be EOL in about 10 months - March 2026. I know that 2026 seems far away but it is not that far in terms of dependencies and upgrades.

Source: https://endoflife.date/ruby

If you are running Ruby on Rails 7.1.x then now would be a good time to schedule upgrade. 
Security support will end on 1st October 2025 - this year.

Source: https://endoflife.date/rails

I used https://endoflife.date for these nice images.

Official maintenance pages

For Ruby you can get the same information about maintenance at: https://www.ruby-lang.org/en/downloads/branches/

For Rails you can get the same information about maintenance at: 
https://rubyonrails.org/maintenance

Written by Lucian Ghinda - Senior Ruby Developer by day, Curator of Short Ruby Newsletter during weekends