title: How should 'conventional' Ember-friendly APIs be designed for creation of mutually dependent parent and child models?
body: <p>I'm building a Rails app with an Ember front-end. I'm trying hard to ensure that the API is as plain, vanilla, RESTful and conventional as possible, in the Rails/Ember spirit.</p>
  
  <p>I'm confused as to how to handle a situation where a parent model requires at least one child, and child models all require the existence of the parent.</p>
  
  <p>Here's a somewhat contrived example:  </p>
  
  <pre><code>class Meal &lt; ActiveRecord::Base
    has_one :appetizer
    has_one :entree
    has_many :side_dishes
    has_many :desserts
  
    # ensures there is AT LEAST one appetizer, entree, side dish or dessert
    validate :plate_is_not_empty
  
    accepts_nested_attributes_for :appetizer, :entree, :side_dishes, :desserts
  end
  
  class Appetizer &lt; ActiveRecord::Base
    belongs_to :meal
    validates_presence_of :meal
  end
  
  class Entree &lt; ActiveRecord::Base
    belongs_to :meal
    validates_presence_of :meal
  end
  
  class SideDish &lt; ActiveRecord::Base
    belongs_to :meal
    validates_presence_of :meal  
  end
  
  class Dessert &lt; ActiveRecord::Base
    belongs_to :meal
    validates_presence_of :meal
  end
  </code></pre>
  
  <p>In the past (aka pre-Ember, with a standard Rails app), my path was always to create the parent object through the parent controller (would have been MealsController, in this case), with at least one nested child. </p>
  
  <pre><code>snack = Meal.create(:name =&gt; 'Late night snack', :side_dishes_attributes =&gt; {:name =&gt; 'Corn Bread'})
  </code></pre>
  
  <p>then I was free to tack on additional children as needed, later on, as the parent had already been created.</p>
  
  <pre><code>Dessert.create(:name =&gt; "Marshmellow Fluff straight from the jar", :meal =&gt; snack)
  </code></pre>
  
  <p>But what's the best way to handle a situation like this with Ember? I'm assuming it's just a special case that'll require a custom ajax call with the nested attributes, which is fine. But I'm wondering how a situation like this fits into the emerging API standards that Ember is advocating. (And of which I'm a big fan.) </p>