-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 7.0.1
-
Component/s: Associations
-
Environment:We use rails 5.2.1 and just updated mongoid gem version to 7.0.1
After update to mongoid 7.0.1, `dup` method started to raise an error`
NoMethodError:
undefined method `buildings' for #<Quote:0x00007fc276d0d1e0>
Did you mean? _building
_building?
binding
# .../gems/mongoid-7.0.1/lib/mongoid/copyable.rb:77:in `block (2 levels) in process_localized_attributes'
# .../gems/mongoid-7.0.1/lib/mongoid/copyable.rb:76:in `each'
# .../gems/mongoid-7.0.1/lib/mongoid/copyable.rb:76:in `each_with_index'
# .../gems/mongoid-7.0.1/lib/mongoid/copyable.rb:76:in `block in process_localized_attributes'
# .../gems/mongoid-7.0.1/lib/mongoid/copyable.rb:72:in `each'
# .../gems/mongoid-7.0.1/lib/mongoid/copyable.rb:72:in `process_localized_attributes'
# .../gems/mongoid-7.0.1/lib/mongoid/copyable.rb:77:in `block (2 levels) in process_localized_attributes'
# .../gems/mongoid-7.0.1/lib/mongoid/copyable.rb:76:in `each'
# .../gems/mongoid-7.0.1/lib/mongoid/copyable.rb:76:in `each_with_index'
# .../gems/mongoid-7.0.1/lib/mongoid/copyable.rb:76:in `block in process_localized_attributes'
# .../gems/mongoid-7.0.1/lib/mongoid/copyable.rb:72:in `each'
# .../gems/mongoid-7.0.1/lib/mongoid/copyable.rb:72:in `process_localized_attributes'
# .../gems/mongoid-7.0.1/lib/mongoid/copyable.rb:51:in `clone_document'
# .../gems/mongoid-7.0.1/lib/mongoid/copyable.rb:22:in `clone'
We have the following models relation in our project:
class A include Mongoid::Document embeds_many :locations end class Location include Mongoid::Document embeds_many :buildings end class Building include Mongoid::Document end location = Location.create! location.buildings << Building.create! a = A.create! a.locations << location a.dup
So when we call dup on top level class A object the error above is raised
- is related to
-
MONGOID-4679 Can't clone documents with embeds_many and store_as on 7.0.x
- Closed