Using Ember-data and Ember.js, I am trying to load two models with one JSON request. Models have a relation similar to this:
App.Person = DS.Model.extend({ name: DS.attr('string'), dogs: DS.hasMany('App.Dog'), }); App.Dog = DS.Model.extend({ name: DS.attr('string'), owner: DS.belongsTo('App.Person'), });
My server sends JSON as follows:
{ "dog": { "id": 1, "name": "Fido", "owner": { "id": 1, "name": "John Smith", "dogs": [1] } } }
... And yet, the Ember data still sends a request (using findQuery) to my server, trying to get the JSON owner.
I have jsFiddle installed which demonstrates it here . To view the problem, you need to follow this link to activate the route / pattern:
http://fiddle.jshell.net/6kQ8s/2/show/#/dog/1
I did not define findQuery () in my adapter because I do not need to get the data that I have already sent ... Correct?
Does anyone know what I'm doing wrong here?
source share