horrendous monkeypatch, now running with ActiveRecord 3.2.11