Reputation: 2527
I'm attempting to use the latest master branch of ember.js and ember-data.
Here's some details:
window.Links = Ember.Application.create();
Links.Store = DS.Store.extend({
revision: 11,
adapter: 'DS.RESTAdapter'
});
Links.List = DS.Model.extend({
urls: DS.hasMany('Links.Url', { embedded: true })
});
Links.Url = DS.Model.extend({
url: DS.attr('string'),
list: DS.belongsTo('Links.List')
});
When I do the following in the console:
var list = Links.List.find("test");
The API returns the following:
{"list":{"id":"test","urls":[{"id":"44e5aa","url":"http://google.com"}]}}
I can do:
list.get("id") // => "test"
list.urls // => undefined
I can't seem to get the associations to work. Am I doing something wrong?
Upvotes: 0
Views: 783
Reputation: 222
I guess a lot of us are in the same boat -- this is very similar to the issue I posted earlier today and the one I referenced. Hopefully that means we'll have a fix or definitive answer shortly!
You may want to try the following, as recommended by brg:
Links.Store.adapter.serializer.map('Links.List', {
urls: {embedded: 'load'}
});
You would then of course remove your inline embedded statement. It didn't solve my problem, but it may in your case.
Note that there is also an issue with embedded belongsTo associations as documented here.
Upvotes: 1