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
When you POST or PUT a record, the server responds with a new copy of the object in question. Ember will parse this and replace the item in the store with the new copy. I generally override the extractArray
and extractSingle
functions in my adapter. 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
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.