Reset isDirty-flag


#1

I have this two models:

// Subject
export default DS.Model.extend({
    willBeActive: DS.attr('boolean')
})

// StudyPlan
export default DS.Model.extend({
    name: DS.attr('string'),
    subjects: DS.hasMany('subjects'),
    havaChanges: function(){
        var isDirty = this.get('isDirty'), 
         subjectsDirty = this.get('subjects').isAny('isDirty', true);
        return subjectsDirty || isDirty;
    }.property('isDirty', 'subjects.@each.isDirty')
})

I use the EmbeddedRecordsMixin and the ActiveModelAdapter to embed inside the studyPlan payload all the subjects that have changed, but when the promise is resolved the isDirtyflag of each subject remains in true. What can I do to reset the isDirty flag of each subject after saving a StudyPlan?