I am having issues working with the Ember Data fixture adapter. When saving a record, all it’s hasMany relationships are lost.
My models and fixtures look like:
App.User = DS.Model.extend({
name: DS.attr('string'),
projects: DS.hasMany('project', { async: true})
});
App.Project = DS.Model.extend({
name: DS.attr('string'),
user: DS.belongsTo('user')
});
App.User.FIXTURES = [
{ id: 1, name: 'Kris', projects: [1,2] },
{ id: 2, name: 'Luke', projects: [1,2] }
];
App.Project.FIXTURES = [
{ id: 1, name: 'Ember' },
{ id: 2, name: 'Angular' }
];
And I am saving the record using:
App.UsersRoute = Ember.Route.extend({
actions: {
save: function(model) {
var self = this;
model.save().then(function() {
this.transitionTo('users');
});
}
},
model: function(){
return this.store.find('user');
}
});
I have create a JS Bin to illustrate the issue and also posted on Stackoverflow.
Thanks