【发布时间】:2017-08-28 00:05:49
【问题描述】:
我收到以下弃用警告:
DEPRECATION WARNING: The behavior of `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_changes?` instead.
对于此代码:
def send_devise_notification(notification, *args)
# If the record is new or changed then delay the
# delivery until the after_commit callback otherwise
# send now because after_commit will not be called.
if new_record? || changed?
pending_notifications << [notification, args]
else
devise_mailer.send(notification, self, *args).deliver_later
end
end
有人可以用一个例子解释一下弃用警告吗?我不确定我是否正确理解 The new return value will reflect the behavior of calling the method after "save" returned 的含义
我现在可以简单地将changed? 替换为saved_changes? 吗?谢谢
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 ruby-on-rails-5 deprecation-warning