[英]Persisting record error in ember
我正在嘗試像文檔中那樣保留記錄:
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
控制器
POST或PUT記錄時,服務器將以相關對象的新副本作為響應。 Ember將對此進行解析,並用新副本替換商店中的商品。 我通常會在適配器中重寫extractArray
和extractSingle
函數。 如果是常規模式,則可以在ApplicationAdapter
,或者如果它特定於record
類型,則可以在RecordAdapter
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.