我在createRecord
上收到以下错误
Uncaught Error: Assertion Failed: You may not pass `null` as id to the store's find method
此处调用创建记录
var newSchool = this.store.createRecord('deal', {
name: newSchoolName,
timeZone: newTimeZone,
locale: newLanguage,
gradeNames: newGradeNames,
standardSourceIds: newStandardSources,
contentSourceIds: newContentSources,
adminUserId: '511a48a7781200b2cd000001',
numOfToken: 1,
higherEd: higherEd,
dealType: 'institution',
parentDeal: this.get('model.deal')
});
问题在于parentDeal它是一个belongsTo关系,如果我将它改为null则没有错误。
此外,错误仅在切换路由时引发,如果我事先记录this.get(' model.deal'),则会显示该对象。
模型在路径中声明
model: function() {
return Ember.RSVP.hash({
deal: this.store.find('deal', this.get('session.dealId')),
contentSources: this.store.find('contentSource'),
standardSources: this.store.find('standardSource')
});
},
编辑:在kitlers评论之后
我添加了以下内容以停用
deactivate: function() {
var model = this.get('model.deal');
if(model && model.get('isDirty')){
model.get('transaction').save()
}
}
此外,这是商店在ember检查员看来的样子