I have two models with parent-child relationship: training and exercise:
App.Training = DS.Model.extend({
exercises:
@tothda and other readers to follow. As of Ember Data : 1.0.0-beta.10+canary.7db210f29a
the parent is still not designed to make parentTraining.isDirty()
a value of true when a child is rolled back. Ember Data does consider a parent record to be dirty when an attribute is changed, but not when a DS.hasMany
array has changes (this allows save() to work, so you can updated any changes to the parent's attributes on the server).
The way around this for the case mentioned, where you want to do a rollback()
on a newly created child, is to replace the .rollback()
with a .deleteRecord()
on the child record you want to discard. Ember Data then automatically knows to remove it from the DS.hasMany
array then, and you can pat yourself on the back for a rollback well done!