这是一个基本的帖子/评论。
当我创建新评论时,它们会添加一个post: attr()与它们相关的帖子的 id 相匹配的标签。我想制作一个过滤器,以便在选择特定帖子并导航到评论部分时仅加载相关评论。
这种迂回方式的原因是我在使用 ember-model 或 ember-data + 各自的 firebase 适配器时无法添加嵌入式评论。
我也无法保存新评论并在创建时添加comment_ids: []引用App.Post。
如果有人知道如何执行上述任一操作,那也可以。
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()
});