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

Relation not persisted in create

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

      If I have three models A, B and C, where A has_one B, B belongs to A, and B has_many C:

      class A
        include Mongoid::Document
        
        has_one :b
      end
      
      class B
        include Mongoid::Document
        
        belongs_to :a
        has_many :c
      end
      
      class C
        include Mongoid::Document
      
        belongs_to :b
      end
      

      Now this doesn't work:

      a = A.create
      c = C.create
      b = a.create_b :cs => [c]
      

      a and c are created as expected but b is created without the relation with c being created

            Assignee:
            Unassigned Unassigned
            Reporter:
            cousine Omar Mekky
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: