Having strange issue with saving hasMany relationships from a primary model, looking for advice:
My setup:
Ember : 1.11.0-beta.1+canary.48e11592
Ember Data : 1.0.0-beta.14.1
EmberFire : 1.3.2
jQuery : 1.11.2
Relationship (pseudo):
customer hasMany widgets
widget belongsTo customer
addRelatedWidget: function() {
var data = this.get('addWidget');
var model = this.get('model');
var widget = this.store.createRecord('widget', {
name: data.name.trim(),
_time: new Date().getTime(),
customer: model,
});
widget.save().then(function(widget){
model.save();
});
this.set('addWidget', {
name: ''
});
}
Symptoms: When I add a widget from the customer view and persist the save, as above, the Chrome browser I'm adding in correctly shows one instance of the newly saved widget. The data at FireBase is correctly showing the new widget and it's joined to the customer as expected. But, if I have any other browser windows open - doesn't matter if it's another chrome, incognito window, or safari - I get TWO versions of the widget displayed in the list of related widgets.
If I use Ember Developer Toolbar in Chrome to debug, I see two instances of the SAME OBJECT - same id, same ember model:
<ember-app@model:widget::ember1553:-JggK7ByZqaNhrJ4PJyq>
<ember-app@model:widget::ember1553:-JggK7ByZqaNhrJ4PJyq>
And to look at the serialized models from the DS.model.tab tab in Ember toolbar:
Ember Inspector ($E): Object {_time: 1422377911584, customer: "12", name: "Adding", id: "-JggK7ByZqaNhrJ4PJyq"}
Ember Inspector ($E): Object {_time: 1422377911584, customer: "12", name: "Adding", id: "-JggK7ByZqaNhrJ4PJyq"}
They appear to be two exact duplicates of the exact same instance of the model.
So I haven't been able to debug this. Since its not the data at firebase and the working browser shows fine, I wonder if it's the new HTMLBars templating engine in 1.9 ... maybe it's even emberfire handling events incorrectly?
I doubt it's emberfire, since I imagine it wouldn't be possible to have two instances of a related model in the same array, because of the fact that related model data in firebase is stored by -primary-key: true ...
Can anyone guide me on where to start debugging this?
Thanks