-
Type: Bug
-
Resolution: Fixed
-
Priority: Blocker - P1
-
Affects Version/s: 7.0.2
-
Component/s: None
This code now errors out on the 7.0.x Mongoid version. I ran this code on 6.4.2, where it works, but it errors out on 7.0.0, 7.0.1, and 7.0.2.
class TestModel include Mongoid::Document embeds_many :other_models, :class_name => "OtherModel", :store_as => "x" end class OtherModel include Mongoid::Document embedded_in :test_model end m = TestModel.create m.other_models.create m.dup()
It errors with
NoMethodError: undefined method `each_with_index' for nil:NilClass
from /Users/jon/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/mongoid-7.0.0/lib/mongoid/copyable.rb:76:in `block in process_localized_attributes'
because the code at https://github.com/mongodb/mongoid/blob/master/lib/mongoid/copyable.rb#L77 errors because it does not use the "store_as" value to find the attribute.
- related to
-
MONGOID-4598 In Mongoid 7.0.1 clone, dup method is not working with embeds_many -> embeds_many relations
- Closed