Javascript 余烬中的持续记录错误
我正在尝试保存文档中的记录:Javascript 余烬中的持续记录错误,javascript,ember.js,ember-data,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 mod
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
错误:找不到“内容”的模型
在出现新错误时()
在Error.Ember.Error(http://zion-le.work/public/scripts/chat/assets/vendor.js:14061:19)
位于Ember.Object.extend.modelFor(http://zion-le.work/public/scripts/chat/assets/vendor.js:68689:33)
在JSONSerializer.extend.extractSingle(http://zion-le.work/public/scripts/chat/assets/vendor.js:61641:28)
在superWrapper[作为单个](http://zion-le.work/public/scripts/chat/assets/vendor.js:14443:16)
在Ember.Object.extend.extractSave处(http://zion-le.work/public/scripts/chat/assets/vendor.js:61161:21)
在Ember.Object.extend.extractCreateRecord处(http://zion-le.work/public/scripts/chat/assets/vendor.js:61090:21)
在Ember.Object.extend.extract处(http://zion-le.work/public/scripts/chat/assets/vendor.js:61018:37)
在http://zion-le.work/public/scripts/chat/assets/vendor.js:69380:32
在invokeCallback(http://zion-le.work/public/scripts/chat/assets/vendor.js:23164:19)vendor.js:16672
未捕获错误:断言失败:错误:找不到“内容”供应商的模型。js:13224
我认为这是因为我在
咨询
中执行了这段代码,而不是记录
控制器当您发布或放置记录时,服务器会用相关对象的新副本进行响应。Ember将对此进行解析,并用新副本替换存储中的项目。我通常会覆盖适配器中的extractArray
和extractSingle
函数。如果它是一种通用模式,您可以在应用程序适配器中执行,或者如果它特定于记录类型,您可以在记录适配器中执行,这很可能是来自服务器的响应有问题,其中可能包括内容的根标记。