Apply patch for https://github.com/rails/rails/issues/917 to 2-3-stable