我有此代码:
class Request < ApplicationRecord
after_create :create_encounter
before_update :check_changes
after_update :create_encounter
has_many :encounters, dependent: :destroy
def create_encounter
hello = Encounter.new
hello.request_id = self.id
hello.status_change_date = DateTime.now.to_date
hello.notes = self.notes
hello.save
end
def check_changes
end
end
我尝试输入测试数据,但输出错误(对于k = 1)。为什么? 这是我的输出:Output