在ember中持续记录错误

时间:2014-08-20 13:14:48

标签: javascript ember.js ember-data

我正试图在文档中保留记录:

  var record = this.store.createRecord('record',{});
            record.set('record_text',this.get('record_text'));
            record.set('record_time', Math.round(new Date()/1000));
            record.save();

但我收到错误:

Error: No model was found for 'content'
    at new Error (<anonymous>)
    at Error.Ember.Error (http://zion-le.work/public/scripts/chat/assets/vendor.js:14061:19)
    at Ember.Object.extend.modelFor (http://zion-le.work/public/scripts/chat/assets/vendor.js:68689:33)
    at JSONSerializer.extend.extractSingle (http://zion-le.work/public/scripts/chat/assets/vendor.js:61641:28)
    at superWrapper [as extractSingle] (http://zion-le.work/public/scripts/chat/assets/vendor.js:14443:16)
    at Ember.Object.extend.extractSave (http://zion-le.work/public/scripts/chat/assets/vendor.js:61161:21)
    at Ember.Object.extend.extractCreateRecord (http://zion-le.work/public/scripts/chat/assets/vendor.js:61090:21)
    at Ember.Object.extend.extract (http://zion-le.work/public/scripts/chat/assets/vendor.js:61018:37)
    at http://zion-le.work/public/scripts/chat/assets/vendor.js:69380:32
    at invokeCallback (http://zion-le.work/public/scripts/chat/assets/vendor.js:23164:19) vendor.js:16672
Uncaught Error: Assertion Failed: Error: No model was found for 'content' vendor.js:13224

我认为这是因为我在consultation执行此代码而不是record控制器

1 个答案:

答案 0 :(得分:0)

当您发布或发布记录时,服务器会使用相关对象的新副本进行响应。 Ember将解析此并用新副本替换商店中的项目。我通常会覆盖适配器中的extractArrayextractSingle函数。如果是一般模式,您可以在ApplicationAdapter中执行此操作,或者如果它特定于您的record类型,则可以在RecordAdapter中执行此操作。