在rails我有移植来改变生产数据以适应新的验证规则,有几个错误,所以我有2个不同的迁移(它们可能是一个但仍然是两个方面单独运行)一个失败,因为其他验证不满足和副反之亦然
验证是模型中的新功能
validates_uniqueness_of :job_id,:scope => [:day,:time,:user_id,:overtime,:comments],:message => "Duplicate Entry,Please check your data" validates_uniqueness_of :job_id,:message => "Has 2 Entires for same job on same day with same comment"
validates_numericality_of :time,:greater_than => 0,:less_than_or_equal_to => 8 validates_numericality_of :overtime,:greater_than_or_equal_to => 0,:less_than_or_equal_to => 16
我试着重新订购迁移,我得到了相反的结果.