title: Creating Child Records in hasMany Relationship with Ember.Js
body: <p>I haven't found a satisfactory answer through my search, so I figured I'd ask here.</p>
  
  <p>I'm currently using Ember.Js, Ember-Data, and <a href="https://github.com/thomasboyt/ember-firebase-adapter" rel="noreferrer">Ember-Firebase-Adapter</a>, and attempting to create a CRUD application which will create a Parent Record, and then subsequent Child Records to said Parent Records.</p>
  
  <p>(note that DS.Firebase.LiveModel is the Firebase adapter equivalent of DS.Model/Ember.Model)</p>
  
  <p>Here are my models, altered to be generic Post/Comment types</p>
  
  <pre><code>    App.Post = DS.Firebase.LiveModel.extend({
        name: DS.attr('string'),
        body: DS.attr('string'),
        date: DS.attr('date'),
        comments: DS.hasMany('App.Comment', {embedded: 'always'})
      });
  
      App.Comment = DS.Firebase.LiveModel.extend({
        message: DS.attr('string'),
        timestamp: DS.attr('string'),
        post: DS.belongsTo('App.Post', {key: "post_id"})
      });
  </code></pre>
  
  <p>(Should my <code>post_id</code> = <code>post</code>?)</p>
  
  <p>And here is my route for creating <code>Comments</code>:</p>
  
  <pre><code>    App.PostsCommentRoute = Ember.Route.extend({
        setupController: function(controller) {
          controller.set('content', App.Comment.find());
        }
  
      });
  </code></pre>
  
  <p>Here's my controller for the <code>PostsCommentRoute</code>:</p>
  
  <pre><code>    App.PostsCommentController = Ember.ObjectController.extend({
        newMessage: null,
        newTimestamp: null,
  
         saveComment: function() {
          App.Pbp.createRecord({
            message: this.get('newMessage'),
            timestamp: this.get('newTimestamp')
          })
  
  
            App.store.commit();
            this.set('newMessage', null);
            this.set('newTimestamp', null);
  
  
          }
      });
  </code></pre>
  
  <p>I think I may be missing the serializer? And I've read several things on <code>addArray</code> but the things I tried to plug in did not prove fruitful. Because my comments create fine, however they are not associated to the post in anyway in my JSON.</p>
  
  <p>Is there a way for the created <code>Comments</code> to find the related <code>Post_Id</code> and then associate to said <code>Post</code> when created? So my <code>Post</code> JSON has an array of <code>Comment_Ids</code> which then allows them to be displayed with the post?</p>
  
  <p>Any help, or links with good examples would be much appreciated.  I know this is a relatively simple quandary yet I've been stuck on it for some time now :p</p>