我正试图在文档中保留记录:
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
控制器
答案 0 :(得分:0)
当您发布或发布记录时,服务器会使用相关对象的新副本进行响应。 Ember将解析此并用新副本替换商店中的项目。我通常会覆盖适配器中的extractArray
和extractSingle
函数。如果是一般模式,您可以在ApplicationAdapter
中执行此操作,或者如果它特定于您的record
类型,则可以在RecordAdapter
中执行此操作。