Backport #9347 to rails 3.2

Thanks Mike for fixing this, I ran into the same issue on rails 3.2 and it would be nice to get this into 3.2.14