Rails Rails5.1 有个 attribute_changed?问题你们知道怎么解决吗

ad583255925 · 发布于 2017年06月18日 · 最后由 lithium4010 回复于 2017年06月18日 · 319 次阅读
96
def reorder?
 p 'it works' if self.order_num_changed?
end

当我准备在回调里调用attribute_changed?的时候,会出来一句

DEPRECATION WARNING: The behavior of `attribute_changed?` inside of after callbacks will be changing in the next version of Rails. The new return value will reflect the behavior of calling the method after `save` returned (e.g. the opposite of what it returns now). To maintain the current behavior, use `saved_change_to_attribute?` instead. (called from attribute_changed? at /Users/jiyarong/.rvm/gems/ruby-2.3.0@global/gems/activerecord-5.1.1/lib/active_record/attribute_methods/dirty.rb:225)

共收到 1 条回复
8744

你不要在after_save 里面调用这个

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册