我有一个带有before_update回调的模型
def
if !condition
#not update record
end
end我需要这个不更新的东西,如何防止模型更新?
发布于 2011-10-12 03:24:56
self.errors.add(:base, "Some error message")
return false我不认为在更新之前,回调函数是添加验证代码的好地方。您可以对validates_each执行相同的操作。
发布于 2011-10-12 03:01:55
使用custom validator。您不能阻止从before_update更新记录
https://stackoverflow.com/questions/7731023
复制相似问题