class SubA < Base
end
class SubB < Base
belongs_to :foo
validates :foo, presence: true
end
copy = sub_a.dup.becomes SubB
copy.type = SubB.sti_name
copy.save!
保存后,我得到:
#<NoMethodError: undefined method `foo' for #<SubA:0x007faa7b64abb8>>
如果我删除验证,则错误消失。为什么ActiveRecord会调用SubB的验证,但后来认为它仍然是SubA?可能有错误吗?