Fix regression introduced in pull request 8812

See https://github.com/rails/rails/pull/8812#commitcomment-2416514