I have a collection of comments and a collection of posts.
App.Router.map(function () {
this.resource("posts", {
path: "/posts"
});
this.resource("post", {
path: "/:post_id"
}, function () {
this.resource("comments", {
path: "/comments"
});
});
});
App.Post = Ember.Model.extend({
id: attr(),
name: attr(),
comments: Ember.hasMany("App.Comment", {
key: 'comments'
})
if embedded = comments: Ember.hasMany("App.Comment", {
key: 'comments',
embedded: true
})
});
App.Post.url = "/posts";
App.Comment = Ember.Model.extend({
id: attr(),
message: attr(),
post: Ember.belongsTo('App.Post', {
key: 'post'
})
});
How can I either:
- Create a new embedded comment.
- Create a non-embedded comment and have that creation add the
comment_id
intocomment_ids: []
on the Post model.
I can get the post_id
to enter into the comments if non-embedded, but am having difficulty getting the comment_id
added into the post.