I know that I can find out the minimum Ruby version required for a Rails project by looking at rails.gemspec file.
For some Rails versions, the required Ruby version is mentioned in the Release Notes. (I really cannot understand why something fundamental like the minimum Ruby version required is not listed in each and every Release Note or in some dedicated documentation page?!)
Anyway, the 7.0 Release Notes also mention a “preferred” Ruby version (“Ruby 2.7.0+ required, Ruby 3.0+ preferred”).
So my questions are:
What does it mean that a Ruby version is “preferred”?
In case the “preferred” Ruby version is not mentioned, does it mean it is the same as in the last previous release which mentions the “preferred” version?
The “preferred” version is a suggestion for optimal performance and compatibility. It is not a strict requirement. If it is not mentioned, it’s safer to rely on the latest stable version compatible with your Rails version. I refer Ruby & Rails Compatibility Table - FastRuby.io | Rails Upgrade Service very frequently. I think the Rails documentation should include this compatibility table.
And there is a degree of truth to that shading of compatibility. Often times you may find that a newest version of Ruby runs a given app really well most of the time. Until you get into an edge case in a gem or other third-party resource that doesn’t support the new syntax, or worse, has a subtle flaw that the newest Ruby rejects. I am thinking here of how in older 2.x Ruby, you sometimes needed to wrap keyword arguments in a hash literal, while in 3.x those are a compile error. Your app might run well until you hit something that lazily-loads that module, and then Bam!
I suggest you open a Documentation PR for this. Document your findings. Someone from the Rails core team will review. This is the best way to confirm your understanding is right and also contribute to the documentation of Rails. You can learn from the best.