-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Computed alias incompatible with relationships #3902
Comments
If your relationship is named relationships: {
volume: {
data: { type: 'books', id: '1' }
}
} |
Right, but wouldn't the expected behavior of |
Ah, I see what you mean. No, that's not possible :( Relationships are special CPs that ED has to know about beforehand so the alias wouldn't be discovered by ED as a relationship. |
If you want to use a different name for a relationship in your payload, you can specify this within your serializer via the App.AuthorSerializer = DS.JSONAPISerializer.extend({
attrs: {
book: { key: 'volume' }
}
}); Note that there was a bug in If you are using a version of ember-data App.AuthorSerializer = DS.JSONAPISerializer.extend({
keyForRelationship: function(key) {
if ("book" === key) {
return "volume";
}
return this._super(...arguments);
}
}); |
Ah, that's unfortunate :(. I was hoping it would behave like Rails' |
Closing this issue as its working as intended. |
It appears that Ember.computed.alias doesn’t work for populating relationships:
http://emberjs.jsbin.com/kopive/4/edit?html,css,js,output (with alias, non-working), vs this: http://emberjs.jsbin.com/kopive/2/edit?html,css,js,output (sans alias, working)
The text was updated successfully, but these errors were encountered: