Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does Ember complain when pushing an object onto an Ember array?
    primarykey
    data
    text
    <p>I am using <strong>Ember RC6.1</strong> with <strong><a href="https://github.com/ebryn/ember-model" rel="nofollow">Ember Model</a></strong>. When I set the <code>adapter</code> property of a model class to an instance of Ember Model's <code>RESTAdpater</code> class and perform a <code>findAll</code>, an assertion is thrown for each object that is added to the resulting Ember array. The stack trace shows that the object is pushed onto the array, inserted, and then replaced. I am not sure why the latter (replacing) occurs. This might be the result of an implicit sort.</p> <p>For each push, an assertion is thrown stating that the <code>content</code> property of an instance of <code>RecordArray</code> (which inherits from <code>ArrayProxy</code>) should be set before modifying it.</p> <pre><code>Assertion failed: The content property of Ember.RecordArray should be set before modifying it </code></pre> <p>The resulting array behaves normally, but I am wondering if this is a bug in Ember Model or Ember itself. I assume that my code is not responsible for this bug as I do nothing out of the ordinary aside from fetching the data from an API as per documentation of Ember Model.</p> <p>I have added the stack trace below.</p> <pre><code>(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 </code></pre> <p><strong>UPDATE: The call to <code>pushObject</code> is performed by Ember Model. I have added the implementation of <code>addToRecordArrays</code>, the method in which the record is added to the instance of <code>RecordArray</code>.</strong></p> <pre><code>addToRecordArrays: function(record) { if (this._findAllRecordArray) { this._findAllRecordArray.pushObject(record); } if (this.recordArrays) { this.recordArrays.forEach(function(recordArray) { recordArray.pushObject(record); }); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload