mercredi 12 août 2015

Ember Data createRecord Error on switching routes

I'm getting the following error on createRecord

Uncaught Error: Assertion Failed: You may not pass `null` as id to the store's find method

Create record is called here

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')
    });

The problem is with the parentDeal it's a belongTo relationship if I change it to null there's no error.

Also the error is only thrown on switching routes and if I log this.get('model.deal') before hand it shows the object.

The model is declared in the route

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')
});
},




Aucun commentaire:

Enregistrer un commentaire