mercredi 31 janvier 2018

Ember Data does not recognise ID in JSON response

I've been trying to figure this out for the past couple of hours and I thought it might be best to ask for some help at this point. The following error is being thrown after my Ember App posts to my Rails API:

Assertion Failed: Your outcome record was saved to the server, but the response does not have an id and no id has been set client side. Records must have ids. Please update the server response to provide an id in the response or generate the id on the client side either before saving the record or while normalizing the response.

What's strange is that my API is returning a JSON response with an ID (see below).

{
  "producer_objective_outcome": {
    "id":27,
    "type":"ProducerObjectiveOutcome",
    "title":"New outcome"
    "owner": {
      "id":6,
    }
  }
}

As you might already have picked up, ProducerObjectiveOutcome is a subclass of Outcome.

In both my Ember App and Rails API, I have setup ProducerObjectiveOutcome to inherit from Outcome. In my Ember App particular, this is what the model looks like:

// app/models/producer-objective-outcome.js

import Outcome from "./outcome";

export default Outcome.extend({

});

Nothing fancy going on here – I thought it was all pretty straight forward – but for some reason, that error is coming up. I'm hoping one of you marvelous people can help me out with this!

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire