I am stuck in a situation where I shouldn\'t return id
field in the API endpoint. I need to tell ember to use slug
field for / instead of id
You need to specify the attribute that should be used as the primaryKey
in your Adapter. If you want the slug
property to serve as your Post
model id
, define the primaryKey
on your Adapter like this:
DS.RESTAdapter.map('App.Post', {
primaryKey: 'slug'
});
As of Ember-data version 1.0.0-beta.7 canary
, you need to do this instead of the above snippet:
App.PostSerializer = DS.JSONSerializer.extend({
primaryKey: 'slug'
});
I'm not an ember pro, but I had wanted to use a slug instead of an ID recently and did this, wondering if this what you're after? https://stackoverflow.com/a/14967337/472852