Quantcast
Viewing all articles
Browse latest Browse all 4827

Assertion Failed: You modified xy twice

@joconja wrote:

Hey,

I am new to ember.

I want to display async relations of a model but I am running into the You modified "model.posts" twice on <eui@model:user::ember271:vV63NgcG0b4R7pm0th0K> in a single render. error.

I am using the newly generated ember app with these modifications (I omitted the imports):

models/post.js

export default DS.Model.extend({
      message: DS.attr('string')
});

models/user.js

export default DS.Model.extend({
  name: DS.attr('string'),
  posts: DS.hasMany('post', { async: true })
});

routes/user.js

export default Ember.Route.extend({
  model(params) {
    return this.store.findRecord('user', params._id);
  }
});

routes/users.js

export default Ember.Route.extend({
  model() {
    return this.store.findAll('user');
  }
});

templates/user.js

{{#each model.posts as |post|}}
  {{post.message}}
{{/each}}

What am I doing wrong?

Thank you!
Daniel

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4827

Trending Articles