Here's a basic post/comments.
When I create new comments, they're added with a post: attr()
that matches the id of the post with which they relate to. I want to make a filter so that when choosing a specific post and navigating to the comments section only the related comments load.
The reason for such a roundabout way is that I've been unable to add an embedded comment while using either ember-model or ember-data + the respective firebase adapter.
I've also been unable to save a new comment and have that add a reference into comment_ids: []
of App.Post
when created.
If anyone has an idea as how to do either of the above that would work as well.
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({
name: attr(),
comments: Ember.hasMany("App.Comment", {
key: 'comments'
})
});
App.Post.url = "/posts";
App.Comment = Ember.Model.extend({
message: attr(),
post: attr()
});