I am having an issue working with Ember Data Fixture Adapter. When saving a record, all of the record\'s hasMany associations are lost. I have created a simple JS Bin to ill
I hit the same problem and came to the same solution. Surely this is a bug in ember-data?
Here's my solution, the only difference is that I'm modifying JSONSerializer, rather than extended RESTSerializer because I'm using the local storage adapter.:
DS.JSONSerializer.reopen({
serializeHasMany : function(record, json, relationship) {
var key = relationship.key;
var relationshipType = DS.RelationshipChange.determineRelationshipType(
record.constructor, relationship);
if (relationshipType === 'manyToNone'
|| relationshipType === 'manyToMany'
|| relationshipType === 'manyToOne') {
json[key] = Ember.get(record, key).mapBy('id');
// TODO support for polymorphic manyToNone and manyToMany
// relationships
}
}
});