我正在使用 rails 2.3.8 版本是否有任何特殊原因导致 update_attributes 不触发 before_validation 回调
class x < ActiveRecord::Base
before_validation :testing
def testing
debugger
end
end
x.update_attributes(:name => "hello") 不会触发 before_validation
我正在使用 rails 2.3.8 版本是否有任何特殊原因导致 update_attributes 不触发 before_validation 回调
class x < ActiveRecord::Base
before_validation :testing
def testing
debugger
end
end
x.update_attributes(:name => "hello") 不会触发 before_validation
如果你用谷歌搜索这个方法,答案对你来说会很清楚:这里的文档清楚地说明了update_attribute
它没有经过验证过程。update_attributes
如果要触发验证,则应改为使用。