port PR rails/rails#7416
Merge pull request #2 from rails/port_pr_7416

port PR rails/rails#7416