Note that I've added a [pull request](https://github.com/rails/rails/pull/8933) for `3-2-stable` that solves the same problem in a different way. If that's acceptable, it could be back-ported to `3-1-stable` and `3-0-stable`.