コメントのコレクションと投稿のコレクションがあります。
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'
})
});
どうすればよいですか:
- 新しい埋め込みコメントを作成します。
- 埋め込まれていないコメントを作成し、その作成をPost モデルに追加
comment_id
します。comment_ids: []
post_id
埋め込まれていない場合はコメントに入力できますがcomment_id
、投稿に追加するのに苦労しています。