I had assumed that if a model in ember-data contained an id related to a second model, then the id could also be used to establish a belongsTo relationship to the second model object, as per the issue I created here on github. Apparently that is not the case.
Does anyone know the circumstance(s) required to have relationships between two objects that both exist in ember-data's store be related to each other? Do the related objects have to be loaded at the same time? (or come through on the same request in the case of the RESTAdapter) in order for the id references to work? In the event they don't come through on the same request, is there anyway to establish that relationship on later requests without have to add event handlers for the requests that look for relationships and set them manually? Here is an example of the issue I'm seeing:
App.ModelA = DS.Model.extend({
name: DS.attr('string'),
modelBId: DS.attr('number'),
modelB: DS.belongsTo('App.ModelB')
});
App.ModelB = DS.Model.extend({
name: DS.attr('string')
});
App.ModelB.find(2); // returns an object
modelA.get('modelBId'); // returns 2
modelA.get('modelB'); // returns null