1
我有before_update回調軌道3 before_update回調
def
if !condition
#not update record
end
end
的模型,我需要這個不是更新的東西,如何防止模型更新?
我有before_update回調軌道3 before_update回調
def
if !condition
#not update record
end
end
的模型,我需要這個不是更新的東西,如何防止模型更新?
self.errors.add(:base, "Some error message")
return false
我不認爲更新回調之前是一個很好的地方添加驗證碼。你可以用validates_each做同樣的事情。
使用custom validator。你不能阻止更新從before_update記錄