【问题标题】:How do I get the RESTSerializer.extractArray method to work?如何让 RESTSerializer.extractArray 方法工作?
【发布时间】:2014-01-02 13:49:35
【问题描述】:

the API-documentation 复制粘贴“有效负载”和序列化程序我创建了以下 JsFiddle:

http://jsfiddle.net/NQKvy/481/

我收到以下错误:

加载路由时出错:错误:断言失败:您必须在传递给 push 的哈希中包含 id

有什么想法吗?

【问题讨论】:

    标签: ember.js ember-data


    【解决方案1】:

    http://jsfiddle.net/UEaQ4/

    Ember 不使用 normalizeHash。我不知道为什么。 我在将有效负载传递给_super之前更改了它

    payload = { 
      comments: comments.map(function(hash){
        hash.id = hash._id;
        hash.title = hash.comment_title;
        delete hash._id;
        delete hash.comment_title;
        return hash;
      }),
      posts: posts };
    

    并且还将comment._id存储在帖子中而不是评论本身

    postCache[comment.post_id].comments.push(comment._id);
    

    它有效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-10-10
      • 2020-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-07
      • 1970-01-01
      相关资源
      最近更新 更多