I'm using Ember 1.13.3 and ember-data 1.13.5.
I have 2 models with a relationship:
spot:
import DS from 'ember-data';
export default DS.Model.extend({
user: DS.belongsTo('user'),
description: DS.attr('string'),
created_at: DS.attr('date'),
image_src: DS.attr('string')
});
user:
import DS from 'ember-data';
export default DS.Model.extend({
username: DS.attr('string'),
email: DS.attr('string'),
avatar: DS.attr('string'),
spots: DS.hasMany('spot')
});
now I call in all the spots and loop over them. Everything display fine of the spot model; however, when I try to retrieve the user's username spot.user.username
it doesn't work. I checked the network and not even a request is being sent out to users/:user_id
.
I also tried adding asyn: true
:
DS.belongsTo('user', {async: true})
but this also did not work. Is there a new way to do relationships in ember 1.13? I know that the belongsTo call is being reach because it appears as a deprecation in the ember console:
In Ember Data 2.0, relationships will be asynchronous by default. You must set `user: DS.belongsTo('user', { async: false })` if you wish for a relationship remain synchronous.
Aucun commentaire:
Enregistrer un commentaire