samedi 4 novembre 2017

Saving a relation for a new entry with ember

I have a licence model that hasMany licence-versions. When I instantiate a new licence version in the edit route of licence I use this code :

model(params) {
    const licence = this.store.findRecord('licence', params.licence_id);
    return RSVP.hash({
        licence: licence,
        newLicenceVersion: this.store.createRecord({licence: licence})
    });
  }

However, when I save the form containing the licence version, the relationship is empty :

{"data":{"attributes":{"version":"zer"},"relationships":{"licence":{"data":null}},"type":"licence/licence-versions"}}

In the ember inspector, it seems the licence is a promise, but I am not sure why.

What am I doing incorrectly ?




Aucun commentaire:

Enregistrer un commentaire