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

relations/accessors.rb: in setter: undefined method `substitute'

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 12_01_17
    • Component/s: None
    • Labels:
      None

      Description

      Not sure what is happening here. This is like the most basic use case.

      #gem "mongoid", "=3.1.6"
      gem "mongoid", "=4.0.0"
       
      require "mongoid"
       
      puts "Using Mongoid #{Mongoid::VERSION}"
       
      Mongoid.configure {|c| c.connect_to "test"}
       
      class Parent
        include Mongoid::Document
        embeds_many :children
      end
       
      class Child
        include Mongoid::Document
        embedded_in :parent
      end
       
      parent = Parent.new
      child = parent.children.build
      puts "Ok"
      

      Output first with 3.1.6 and then with 4.0.

      mongoid-errors$ruby substitute.rb 
      Using Mongoid 3.1.6
      Ok
      mongoid-errors$ruby substitute.rb 
      Using Mongoid 4.0.0
      /usr/local/Cellar/ruby/2.1.2/lib/ruby/gems/2.1.0/gems/mongoid-4.0.0/lib/mongoid/relations/accessors.rb:231:in `block (2 levels) in setter': undefined method `substitute' for #<Parent _id: 53f4e547616d7722fb000000, > (NoMethodError)
      	from /usr/local/Cellar/ruby/2.1.2/lib/ruby/gems/2.1.0/gems/mongoid-4.0.0/lib/mongoid/relations/accessors.rb:140:in `without_autobuild'
      	from /usr/local/Cellar/ruby/2.1.2/lib/ruby/gems/2.1.0/gems/mongoid-4.0.0/lib/mongoid/relations/accessors.rb:229:in `block in setter'
      	from /usr/local/Cellar/ruby/2.1.2/lib/ruby/gems/2.1.0/gems/mongoid-4.0.0/lib/mongoid/extensions/object.rb:104:in `do_or_do_not'
      	from /usr/local/Cellar/ruby/2.1.2/lib/ruby/gems/2.1.0/gems/mongoid-4.0.0/lib/mongoid/relations/bindings/embedded/many.rb:26:in `block in bind_one'
      	from /usr/local/Cellar/ruby/2.1.2/lib/ruby/gems/2.1.0/gems/mongoid-4.0.0/lib/mongoid/relations/binding.rb:38:in `block in binding'
      	from /usr/local/Cellar/ruby/2.1.2/lib/ruby/gems/2.1.0/gems/mongoid-4.0.0/lib/mongoid/threaded/lifecycle.rb:55:in `_binding'
      	from /usr/local/Cellar/ruby/2.1.2/lib/ruby/gems/2.1.0/gems/mongoid-4.0.0/lib/mongoid/relations/binding.rb:37:in `binding'
      	from /usr/local/Cellar/ruby/2.1.2/lib/ruby/gems/2.1.0/gems/mongoid-4.0.0/lib/mongoid/relations/bindings/embedded/many.rb:25:in `bind_one'
      	from /usr/local/Cellar/ruby/2.1.2/lib/ruby/gems/2.1.0/gems/mongoid-4.0.0/lib/mongoid/relations/proxy.rb:26:in `bind_one'
      	from /usr/local/Cellar/ruby/2.1.2/lib/ruby/gems/2.1.0/gems/mongoid-4.0.0/lib/mongoid/relations/embedded/many.rb:390:in `integrate'
      	from /usr/local/Cellar/ruby/2.1.2/lib/ruby/gems/2.1.0/gems/mongoid-4.0.0/lib/mongoid/relations/embedded/many.rb:328:in `append'
      	from /usr/local/Cellar/ruby/2.1.2/lib/ruby/gems/2.1.0/gems/mongoid-4.0.0/lib/mongoid/relations/embedded/many.rb:83:in `build'
      	from substitute.rb:21:in `<main>'
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              amw Adam Wróbel
              Participants:
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: