Fix activerecord create or update bug