Apply patch https://github.com/rails/rails/pull/8189/