Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-3671

"undefined method `substitute' on an instance of" for embedded docs

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 5.0.2
    • Affects Version/s: None
    • Component/s: None

      with the current 4beta2 I'm seeing these errors quite frequently:

      rbx-2.2.7 :012 > Dokument.first
      Hirb Error: undefined method `substitute' on an instance of Dokument.
          kernel/delta/kernel.rb:78:in `substitute (method_missing)'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/accessors.rb:231:in `setter'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/accessors.rb:140:in `without_autobuild'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/accessors.rb:229:in `setter'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/extensions/object.rb:104:in `do_or_do_not'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/bindings/embedded/many.rb:26:in `bind_one'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/binding.rb:38:in `binding'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/threaded/lifecycle.rb:55:in `_binding'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/binding.rb:37:in `binding'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/bindings/embedded/many.rb:25:in `bind_one'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/proxy.rb:26:in `bind_one'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/embedded/many.rb:390:in `integrate'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/embedded/many.rb:236:in `initialize'
          kernel/common/enumerable.rb:202:in `each_with_index'
          kernel/bootstrap/array.rb:76:in `each'
          kernel/common/enumerable.rb:200:in `each_with_index'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/embedded/many.rb:235:in `initialize'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/proxy.rb:42:in `init'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/embedded/many.rb:234:in `initialize'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/accessors.rb:44:in `create_relation'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/accessors.rb:26:in `__build__'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/accessors.rb:104:in `get_relation'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/threaded/lifecycle.rb:125:in `_loading'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/accessors.rb:100:in `get_relation'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/threaded/lifecycle.rb:84:in `_building'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/accessors.rb:99:in `get_relation'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/accessors.rb:187:in `getter'
          /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/hirb-0.7.2/lib/hirb/helpers/object_table.rb:10:in `render'
      

      They happen too, if I try to do this on a document with embedded docs:

      d.class.new(d.attributes)
      

      e.g.

      NoMethodError: undefined method `substitute' on an instance of Dokument.
              from kernel/delta/kernel.rb:78:in `substitute (method_missing)'
              from /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/accessors.rb:231:in `setter'
              from /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/accessors.rb:140:in `without_autobuild'
              from /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/accessors.rb:229:in `setter'
              from /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/extensions/object.rb:104:in `do_or_do_not'
              from /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/bindings/embedded/many.rb:26:in `bind_one'
              from /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/binding.rb:38:in `binding'
              from /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/threaded/lifecycle.rb:55:in `_binding'
              from /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/binding.rb:37:in `binding'
              from /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/bindings/embedded/many.rb:25:in `bind_one'
              from /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/proxy.rb:26:in `bind_one'
              from /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/embedded/many.rb:390:in `integrate'
              from /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/embedded/many.rb:328:in `append'
              from /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/embedded/batchable.rb:269:in `pre_process_batch_insert'
              from kernel/bootstrap/array.rb:97:in `map'
              from /opt/dokmatic1/vendor/bundle/rbx/2.1/gems/mongoid-4.0.0.beta2/lib/mongoid/relations/embedded/batchable.rb:267:in `pre_process_batch_insert'
      ... 22 levels...
              from kernel/bootstrap/proc.rb:20:in `call'
              from kernel/common/throw_catch.rb:30:in `catch'
              from kernel/common/throw_catch.rb:8:in `register'
              from kernel/common/throw_catch.rb:29:in `catch'
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            fwoeck fwoeck
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: