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

1-1 embedded child not touching parent

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

      On mongoid 3.1.1. Thanks again

      class Parent
        include Mongoid::Document
        include Mongoid::Timestamps
      
        field :name
      
        embeds_one :child
      end
      
      class Child
        include Mongoid::Document
        include Mongoid::Timestamps
      
        field :name
      
        embedded_in :parent
      end
      
      1.9.3p194 :004 > Parent.delete_all
       => 1 
      1.9.3p194 :005 > Parent.create(child: Child.new)
       => #<Parent _id: 51267e99499c194060000003, created_at: 2013-02-21 20:07:53 UTC, updated_at: 2013-02-21 20:07:53 UTC, name: nil> 
      1.9.3p194 :006 > u = Parent.first.updated_at
       => Thu, 21 Feb 2013 20:07:53 UTC +00:00 
      1.9.3p194 :007 > c = Parent.first.child
       => #<Child _id: 51267e99499c194060000004, created_at: nil, updated_at: nil, name: nil> 
      1.9.3p194 :008 > c.name = "Touch the parent"
       => "Touch the parent" 
      1.9.3p194 :009 > c.save
       => true 
      1.9.3p194 :010 > u == Parent.first.updated_at
       => true 
      1.9.3p194 :011 > Parent.first
       => #<Parent _id: 51267e99499c194060000003, created_at: 2013-02-21 20:07:53 UTC, updated_at: 2013-02-21 20:07:53 UTC, name: nil> 
      1.9.3p194 :013 > Parent.first.child
       => #<Child _id: 51267e99499c194060000004, created_at: nil, updated_at: 2013-02-21 20:08:12 UTC, name: "Touch the parent">
      

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

              Created:
              Updated:
              Resolved: