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:
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: http://stackoverflow.com/questions/18587754/ember-data-whats-the-correct-way-to-update-relations-after-saving-a-record)