0

我的孩子模型:

    include Mongoid::Document
    include Mongoid::Timestamps
    belongs_to :dedicated_to, polymorphic: true , touch: true

我的父模型:

include Mongoid::Document
include Mongoid::Timestamps
has_many :dedications, as: :dedicated_to

现在看到这个:

irb(main):050:0> Parent.find("523aab9f8c1ec39417000242").dedications.first.touch
=> true
irb(main):050:0> a = Parent.find("523aab9f8c1ec39417000242").dedications.first.dedicated_to
irb(main):050:0> b = Parent.find("523aab9f8c1ec39417000242")
irb(main):050:0> a == b
=> true
irb(main):050:0> a.updated_at
=> Sat, 21 Sep 2013 19:45:08 UTC +00:00
irb(main):050:0> b.updated_at
=> Sun, 22 Sep 2013 15:54:55 UTC +00:00

如您所见,我们在这里遇到了一个意想不到的悖论。a 已更新,但 b 未更新。甚至它说 a = b !

4

0 回答 0