I'm using the RESTAdaptor and Ember-Data 1.0.0-beta-2. I'm following the guidance in the Ember docs http://emberjs.com/guides/models/connecting-to-an-http-server/ about how the JSON returned from the server should be formatted for belongsTo relationships - but the related object is not being loaded. The Ember Inspector in Chrome is always showing the relationship as null.
The format of my JSON from the server is as follows:
{
"danceStyle": {
"id": 2,
"name": "Balboa",
"partnered": true,
"_links": {
"parent": "/danceStyles/1"
}
}
}
And my Model definition is:
var attr = DS.attr;
var belongsTo = DS.belongsTo;
var hasMany = DS.hasMany;
App.DanceStyle = DS.Model.extend({
object: attr('string'),
name: attr('string'),
partnered: attr('boolean'),
parent: belongsTo('danceStyle', { inverse: 'children', async: true }),
children: hasMany('danceStyle', { inverse: 'parent', async: true })
});
The format of my JSON matches up to the format that the Ember docs say I should be using, so I'm banging my head against the wall trying to work out what's wrong! I've tried other ways of including the relationship within the JSON but with no results.