There was commit to Ember data and delivered with ember-data 1.0.0.-beta4 that broke my code.
Just in case you face similar issue, sharing this with you.
In that commit guy fixes issue with oneToMany relationship, when child items if they were not saved (i.e. are still in ‘isNew’ state) won’t be in list of child items after parent got saved. Apparently this happens because server doesn’t return unsaved child items.
Please see my comment and corresponding commit:
This is completely fine for traditional REST backend that handles each item separately, but what we implemented at work is backend that handles parent item with all child items. So request/response is complete graph. In our case all child items are automatically saved with parent object. Since server returns child item it will be in list of child items. Instead code that guy committed will add child item once again, since object in memory is still with ‘isNew’ state.
This is my fix
, that I’ve added to our DS.ApplicationStore
Basically it recursively marks all child items as committed before base didSaveRecord is called and attempts to add them if state is ‘isNew’.
You can notice that changing state is bit crazy – calling adapterWillCommit and adapterDidCommit, but it was only one way I found to do this. Unfortunately state manager is no longer part of ember.
Hope this helps someone.
[Update 2015/07/08: Looks like this got fixed as of ember-data 1.0.0.-beta4]