Question

I made an API that return in a JSON format a catalog. The problem is that the "id" is not named "id", but "catalog_id". When I do :

return this.store.find('catalog', 1);

* Note that the I have set my adapter to :

DS.RESTAdapter.reopen({
  namespace: 'web/app_dev.php'
});

Here's what my api returns:

enter image description here

Unfortunatly, Ember-data translate this into : enter image description here

EDIT: this image is too small, here's the link for full size : http://i.imgur.com/oZA6H6q.png

Any idea how I can fix this issue? I would like not to rename my "category_id" into "id". I would have to do lots of refactoring and I don't want this.

Cheers.

EDIT #2: Note that my console return the following error : Assertion failed: You must include an id in a hash passed to push

Was it helpful?

Solution

The id key name is defined by the primaryKey propety from RESTSerializer. You can override this using:

App.CatalogSerializer = DS.RESTSerializer.extend({ 
    primaryKey: 'catalog_id' 
});

I hope it helps

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top