-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
Related to issue MONGOID-3009 - perhaps a generalized problem. has_many / belongs_to does not properly update the inverse relation when the identity map is enabled.
class Image include Mongoid::Document belongs_to :page end class Page include Mongoid::Document has_many :images end describe Mongoid do def check_inverse_relation i = Image.new i.save! p = Page.new i.page = p p.save! i.page.should_not be nil p.images.length.should == 1 # this fails with identity map enabled end it "works with identity map off" do Mongoid.identity_map_enabled = false check_inverse_relation end it "fails with idenity map on" do Mongoid.identity_map_enabled = true check_inverse_relation end end
(Please tell me I'm doing it wrong because I'd love the problem to be in my code not mongoid.)