I am working on a simple tag model for one of my projects. I implemented something similar in Angular, but I wanted to try it out in Ember. Model Code Below
Tag = DS.Model.extend {
name:DS.attr('string')
user:DS.belongsTo('user')
appliedTags:DS.hasMany('AppliedTag')
obliterate:()->
this.get('appliedTags').forEach( (appliedTag)->
console.log(Ember.inspect(appliedTag))
appliedTag.destoryRecord()
)
this.destroyRecord()
}
fixtures = [
id:1
name:'Category 1'
user:1
appliedTags:[1,5]
]
Tag.reopenClass
FIXTURES: fixtures
Everything is fine if I comment appliedTag.destoryRecord(). However, for the second time through the loop, it forEach appliedTaghas the value undefined .
source
share