rails/rails — pull request #4482 by alexeymuranov (2012-01-16 21:32:13+00:00)
Title: Backport PR #4153 and #4224 to 3-1-stable 

This is a rebase of commits from PR #4153 and #4224 to `3-1-stable`, with minor changes in two commits.