Suggested fix for https://github.com/rails/rails/issues/12253

Suggested fix for https://github.com/rails/rails/issues/12253