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

Default 1-N Embedded Documents

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.0.7
    • Affects Version/s: None
    • Component/s: None

      Having a bit of trouble.

      class Item
        include Mongoid::Document
        embedded_in :report
      end
      
      class Report
        include Mongoid::Document
        embeds_many :items
      
        after_initialize do |report|
          report.items = [Item.new, Item.new]
        end
      end
      
      NoMethodError (undefined method `find' for nil:NilClass):
        app/models/report.rb:14:in `block in <class:Report>'
        app/controllers/reports_controller.rb:6:in `new'
      

      Is there anything I did wrong?

      Thanks again. You guys are awesome.

            Assignee:
            durran Durran Jordan
            Reporter:
            s12chung s12chung
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: