title: saving embeds_many in mongoid
body: <p>I have a embeds_many association and when I save the parent document the children are not being saved.</p>
  
  <pre><code>class User
    include Mongoid::Document
  
    embeds_many :user_missions
    attr_accessible :user_missions_attributes
    accepts_nested_attributes_for :user_missions, allow_destroy: true
  end
  
  class UserMission
    include Mongoid::Document
  
    embedded_in :user, :inverse_of =&gt; :user_missions
  
    has_one :mission, autosave: true
    validates_presence_of :mission
  
    attr_accessible :mission_title
  
    def mission_title
      mission.try(:title)
    end
  
    def mission_title=(title)
      self.mission = Mission.find_or_create_by(:title =&gt; title) if title.present?
    end
  end
  </code></pre>
  
  <p>Here is the spec I'm failing:</p>
  
  <pre><code>it "should save mission to user_mission when created" do
    user_mission = UserMission.new
    user = create(:user)
    user.user_missions &lt;&lt; user_mission
    user_mission.mission_title = "Created Title"
  
    user.save!
    #user_mission.save!
  
    User.first.user_missions[0].mission.title.should == "Created Title"
  end
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>undefined method `title' for nil:NilClass
  </code></pre>
  
  <p>When I comment in the line <code>#user_mission.save!</code> it works.  The problem is I need this to work in a form and I thought Mongoid automatically saved embedded document's fields.</p>
  
  <p>How do I get the parent User document to save the embedded UserMission's data?</p>
  
  <p>Thanks</p>
  
  <p>UPDATE</p>
  
  <p>Here is the Mission model I forgot to add (wasn't sure if it was important):</p>
  
  <pre><code>class Mission
    include Mongoid::Document
  
    belongs_to :user_mission, :inverse_of =&gt; :mission
  
    attr_accessible :title
    field :title, type: String
    validates_presence_of :title
  
    field :lowercase_title
    before_create :lower_title_case
  
    field :description, type: String
  
  private
    def lower_title_case
      self.lowercase_title = self.title.downcase
    end
  end
  </code></pre>