I have this code in an Ember route:
let forum = this.store.findRecord('forum', 'main').then(function(forum) {
console.log('FORUM:', forum);
let categories = forum.get('categories');
console.log('CATEGORIES:', categories);
});
return forum;
This console returns this:
FORUM: Object { store: Object, _internalModel: Object, id: Getter, currentState: Object, isError: false, adapterError: null, OWNER [id=__ember1476462923058714220863537]: Object, _super: ROOT(), 2 more… }
CATEGORIES: undefined
Obvisouly, a request is made to /forums/main
, but nothing after that. What is the role of forum.get('categories')
? How am I supposed to get the relationships of a resource? Shouldn't that request /forums/main/categories
?
Forum:
export default DS.Model.extend({
// Attributes
language: DS.attr('string'),
// Relationships
categories: DS.hasMany('category', { async: true }),
});
Category:
export default DS.Model.extend({
// Attributes
name: DS.attr('string'),
// Relationships
forum: DS.belongsTo('forum', { async: true }),
boards: DS.hasMany('board', { async: true })
});
Router (relevant part):
this.route('community', function() {
this.route('players');
this.route('forum', function() {
});
});