title: Mongoid Create New Embedded Document Inside Parent
body: <p>I have two models I am working with Events and Reports. Reports and embedded in Events. I am having trouble creating a new report for a particular event.</p>
  
  <p>I think my Report Controller new action needs to look something like this:</p>
  
  <pre><code>@event = Event.find(params[:eventid])
  @report = @event.report.build
  </code></pre>
  
  <p>In my Event model I have the following set:</p>
  
  <pre><code>embeds_one :report
  accepts_nested_attributes_for :report
  </code></pre>
  
  <p>When I try to save I receive the following error:</p>
  
  <pre><code>Mongoid::Errors::NoParent
  </code></pre>
  
  <p>Here is my Report Model</p>
  
  <pre><code>class Report
  include Mongoid::Document
  include Mongoid::Timestamps
  field :test, type: String
  embedded_in :event, :inverse_of =&gt; :report
  embeds_many :report_details
  accepts_nested_attributes_for :report_details,
    :allow_destroy =&gt; true, 
      :reject_if =&gt; proc { |attributes| 
        attributes['name'].blank? &amp;&amp; attributes['_destroy'].blank? 
      }
  </code></pre>
  
  <p>And here is my Event Model</p>
  
  <pre><code>class Event
  include Mongoid::Document
  include Mongoid::Timestamps
  embeds_one :report
  accepts_nested_attributes_for :report,
  :allow_destroy =&gt; true, 
    :reject_if =&gt; proc { |attributes| 
      attributes['name'].blank? &amp;&amp; attributes['_destroy'].blank? 
    }
  </code></pre>
  
  <p>Thanks in advance.</p>