Many to many relationship issues



I have posts with categories. On post can have different categories and one category can belong to different posts.

My models are as follow:


export default DS.Model.extend({
  slug: DS.attr(),
  title: DS.attr(),
  teaser: DS.attr(),
  body: DS.attr(),
  media: DS.belongsTo('media', {async: true}),
  date: DS.attr("date"),
  author: DS.belongsTo('user', {async: true}),
  categories: DS.hasMany('category', {async: true}),
  featured_position: DS.attr(),


export default DS.Model.extend({
  description: DS.attr(),
  name: DS.attr(),
  slug: DS.attr(),
  taxonomy: DS.attr(),
  parent: DS.attr(),
  posts: DS.hasMany('post', {async: true}),

Next I bring all the posts in my model:



After that I loop through all the posts in my template:


{{#each model as |post|}}
	{{#each category in post.categories}}
		Category: {{}}

So when I do this, all of the other attributes get printed alright, including the attributes with a belongsTo, but the categories are blank.

Additionally if I look at the Ember Inspector the category data is being fetched from the backend. The problem is that the data is not being referenced between the post and the category.

Is there something else that I have to take into account when doing a many to many relationship in Ember?


Answered on reddit.


Yes, thanks for your help.