[英]Persisting record error in ember
I'm trying to persist record like in the documentation: 我正在尝试像文档中那样保留记录:
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();
But I receive error: 但我收到错误:
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
I think it's happened because I execute this code in consultation
instead record
controller 我认为这是因为我在
consultation
执行了此代码,而不是record
控制器
When you POST or PUT a record, the server responds with a new copy of the object in question. POST或PUT记录时,服务器将以相关对象的新副本作为响应。 Ember will parse this and replace the item in the store with the new copy.
Ember将对此进行解析,并用新副本替换商店中的商品。 I generally override the
extractArray
and extractSingle
functions in my adapter. 我通常会在适配器中重写
extractArray
和extractSingle
函数。 If it is a general pattern, you can do it in your ApplicationAdapter
, or if it is specific to your record
type, you can do it in the RecordAdapter
. 如果是常规模式,则可以在
ApplicationAdapter
,或者如果它特定于record
类型,则可以在RecordAdapter
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.