Add activerecord functions