class ActiveRecord::Associations::BelongsToAssociation

def target_changed?

def target_changed?
  owner.attribute_changed?(reflection.foreign_key) || (!foreign_key_present? && target&.new_record?)
end