Skip to content

Instantly share code, notes, and snippets.

@SlyDen
Created February 21, 2017 12:55
Show Gist options
  • Save SlyDen/2e10826d1d3161340f910edd533ae99f to your computer and use it in GitHub Desktop.
Save SlyDen/2e10826d1d3161340f910edd533ae99f to your computer and use it in GitHub Desktop.
// app/models/post.js
export default DS.Model.extend({
body: DS.attr(),
comments: DS.hasMany(),
addComment(commentData) {
let store = Ember.getOwner(this).lookup('service:store');
let comment = store.createRecord('comment', commentData);
this.get('comments').pushObject(comment);
return comment.save().then(() => {
return this.save();
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment