Ember Data 1.0 Beta - Relations lost because record is not de-serialized after save?

I’m relatively new to Ember and Ember Data and have run into an issue around relations and I can’t tell if this is a bug or expected behavior.

When I fetch records from the server my models are properly deserialized and their hasMany relations are properly set and can be accessed as one would expect.

However, when I create a new record, the model is properly serialized before being sent to the server and the response payload includes the relations as an array of ids in the same format as the records that were received when performing the original fetch. When the save operation is complete, the model has “lost” its relations because it was updated with POST response and not deserialized.

I can re-initialize the relations by calling:

model.get('store').push('modelType', model.get('data'));

This appears to work but I would expect the model to be deserialized “automagically” after a successful save.

Is this assumption correct or is it expected that records be manually deserialized after being created/saved?

(fwiw, I originally posed this question at SO, before I realized that re-pushing the model would deserialize the model. Before filing an issue on Github I thought it would be best to raise the question here. The original SO question is here: ember.js - Ember Data - What's the correct way to update relations after saving a record? - Stack Overflow)


I was bitten by this today, too. It makes no sense that records aren’t deserialized after save, so I assume this is an oversight. I’ve opened issue #1214 about this: https://github.com/emberjs/data/issues/1214

1 Like

Yeah, I discussed with another dev and we both agreed that it seems like a bug. Thanks for filing the issue on Github!