This Week in Rails

October 20, 2023

Rails World talks online, fix of a 13 years old bug and more!

Hi, it’s Greg, bringing you this week’s changes in the Rails codebase.

Rails World talks are online
The talks from Rails World 2023 are now available to watch online! You can watch all of them on the YouTube playlist.
Also, Amanda Perino wrote a recap of Rails World.

Do not memoize auto/eager load paths in engines
This pull request fixes an issue from 13 years ago. In a Rails engine, if you manipulate the auto/eager load paths like this:

config.eager_load_paths << "#{Rails.root}/extras"
config.paths["app/helpers"] << "#{Rails.root}/custom/helpers"


Then custom/helpers would not end up in the autoload and eager load paths. In newly generated Rails 7.1 applications lib is pushed to to config.eager_load_paths. If they are used together with something that edits config.paths afterwards, that latent bug now surfaces. I guess this combination, while possible, was not happening much in practice until now.

Raise on foreign_key: being passed as an array in associations
Associations have never allowed nor supported foreign_key option being passed as an Array. This still holds true for Rails 7.1. However, with support for composite primary keys it may become more common for applications to mistakenly pass an array to foreign_key:. With this commit, an exception is raised when foreign_key: is passed as an array.

Fix capture view helper for HAML and Slim
When a blank string is captured in HAML or Slim (and possibly other template engines) it returns an entire buffer. This pull request fixes that.

You can view the whole list of changes here.
We had 26 contributors to the Rails codebase this past week!

Until next time!

About This Week in Rails

Your weekly inside scoop of interesting commits, pull requests and more from Rails.