fixed activerecord api to support rails4