Added activerecord hook