【发布时间】:2018-06-28 20:17:46
【问题描述】:
我在运行 RSpec 测试时收到如下警告
弃用警告:
attribute_changed?内部的行为 after 回调将在下一版本的 Rails 中更改。新的 返回值将反映调用该方法后的行为save返回(例如,与现在返回的相反)。至 保持当前行为,使用saved_change_to_attribute?反而。 (在 (pry):12 从 set_about_page_title 调用)
class User < ApplicationRecord
after_create :create_defaults
def create_defaults
set_about_page_title
set_contact_page_title
self.save
end
def set_about_page_title
self.about_page_title = self.full_name
end
def set_contact_page_title
self.contact_page_title = User::GET_IN_TOUCH
end
end
【问题讨论】:
标签: ruby-on-rails ruby rspec