I've filed a ticket here with details and a proposed patch. Would someone please take a look at it?
https://rails.lighthouseapp.com/projects/8994/tickets/2533