Record with hasMany association is not set to dirty #247

pangratz opened this Issue May 7, 2012 · 4 comments


None yet
2 participants

pangratz commented May 7, 2012

I would expect the post to be dirty when an object is added to a hasMany association, see

App = Ember.Application.create({});

App.Comment = DS.Model.extend({
    text: DS.attr('string')

App.Post = DS.Model.extend({
    text: DS.attr('string'),
    comments: DS.hasMany('App.Comment')
}); = DS.Store.create({
    revision: 4
});, {id: 1, text: 'first post'});, {id: 2, text: 'first comment'});

var post = App.Post.find(1);
console.log('post is dirty', post.get('isDirty'));
console.log('number of comments', post.getPath('comments.length'));

var comment = App.Comment.find(2);

var comments = post.get('comments');

console.log('post is dirty', post.get('isDirty')); // Y U NO DIRTY?
console.log('number of comments', post.getPath('comments.length'));​

tchak commented May 7, 2012

not it is the comment that gets dirty, this not a bug
belongsTo define the foreignKey


pangratz commented May 7, 2012

Thanks for you quick reply @tchak !

My backend is a CouchDB and the foreign keys are defined in the Post model like stated in the example. Is there a way to get this working with the current ember data?

I have seen #53 and @wycats latest response. Will those kind of nested hasMany associations be possible when #53 is closed?


tchak commented May 7, 2012

I think what you looking for is #195, and yes it looks like it all will be adressed by upcoming redesign


pangratz commented May 8, 2012

Okay, thanks again!

@pangratz pangratz closed this May 8, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment