我使用 Ember Model Ember RC6.1 。当我将模型类的adapter
属性设置为Ember Model的RESTAdpater
类的实例并执行findAll
时,会为添加到生成的Ember数组的每个对象抛出一个断言。堆栈跟踪显示对象被推入阵列,插入,然后替换。我不确定为什么会发生后者(替换)。这可能是隐式排序的结果。
对于每次推送,都会抛出一个断言,指出在修改它之前应该设置content
实例的RecordArray
属性(继承自ArrayProxy
)。
Assertion failed: The content property of Ember.RecordArray should be set before modifying it
生成的数组表现正常,但我想知道这是否是Ember Model或Ember本身的错误。我假设我的代码不对这个错误负责,因为除了根据Ember Model的文档从API中获取数据之外我什么都不做。
我在下面添加了堆栈跟踪。
(anonymous function) application.js:6108
Ember.assert application.js:5799
Ember.ArrayProxy.Ember.Object.extend._replace application.js:17977
Ember.ArrayProxy.Ember.Object.extend._insertAt application.js:17992
Ember.ArrayProxy.Ember.Object.extend.pushObject application.js:18036
superWrapper application.js:6826
Ember.Model.reopenClass.addToRecordArrays application.js:5251
(anonymous function) application.js:5242
sendEvent application.js:7843
Ember.Evented.Ember.Mixin.create.trigger application.js:16867
Ember.Model.Ember.Object.extend.load application.js:4792
Ember.Model.reopenClass.findFromCacheOrLoad application.js:5280
(anonymous function) application.js:4453
Ember.RecordArray.Ember.ArrayProxy.extend.materializeData application.js:4452
Ember.RecordArray.Ember.ArrayProxy.extend.load application.js:4435
Ember.RESTAdapter.Ember.Adapter.extend.didFindAll application.js:5585
(anonymous function) application.js:5576
invokeCallback application.js:12843
(anonymous function) application.js:12886
EventTarget.trigger application.js:12674
(anonymous function) application.js:12941
DeferredActionQueues.flush application.js:10648
Backburner.end application.js:10338
Backburner.run application.js:10377
Ember.run application.js:10859
settings.success application.js:5697
fire application.js:38117
self.fireWith application.js:38228
done application.js:45154
callback
更新:对pushObject
的调用由Ember Model执行。我添加了addToRecordArrays
的实现,这是将记录添加到RecordArray
实例的方法。
addToRecordArrays: function(record) {
if (this._findAllRecordArray) {
this._findAllRecordArray.pushObject(record);
}
if (this.recordArrays) {
this.recordArrays.forEach(function(recordArray) {
recordArray.pushObject(record);
});
}
}
答案 0 :(得分:1)
我已经恢复了引入此问题的提交。