Ember Data does not recognise ID is JSON Response

Hi all,

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! :slight_smile:

For anyone who is interested, I solved this by changing the name of the root node of the JSON response to outcome instead of it being producer_objective_outcome.

What may have helped in my earlier explanation is that the ProducerObjectiveOutcome record was being created at the following route: producer/objective/:id/outcome/new.

The key part of this URI, as I have figured just out, is the .../outcome/... section. I haven’t tested otherwise, but given the conventions in Ember, I suspect that if that URI was .../producer-objective-outcome/... then everything would have been hunky dory. :slight_smile: