title: How to directly store a hash of model with has_many relationship without using .new (without initializing object) in Rails Mongoid?
body: <p>Suppose I have these models in rails.</p>
  
  <p><strong>ParentObject Model</strong></p>
  
  <pre><code>class ParentObject
    include Mongoid::Document
    has_many :child_objects, autosave: true, dependent: :destroy
    accepts_nested_attributes_for :child_objects
  
    field :p_test_field, type: String
    field :p_test_field_two, type: String
  end
  </code></pre>
  
  <p><strong>ChildObject Model</strong></p>
  
  <pre><code>class ChildObject &lt; ParentObject
    include Mongoid::Document
  
    belongs_to :parent_object
  
    field :c_test_field, type: String
    field :c_test_field_two, type: String
  end
  </code></pre>
  
  <p>Now to save data I use this code.</p>
  
  <pre><code>@parent_object = ParentObject.new(parent_object_params)
  @parent_object.child_objects_attributes = {"0" =&gt; {:c_test_field =&gt; "test2"}}
  @parent_object.save
  </code></pre>
  
  <p>So that is how data is saved. Now I want to save data using a hash without using the .new method , i.e. without initializing the object. How can that be done? I just want to store from a hash which has values for child object as well as parent object. What would be the format for that hash? I mean I don't even have a parent_object_id</p>
  
  <p><strong>My primary object is to batch insert the data into parent and child object no matter how.</strong></p>