I got an issue when i try to add an embedded belongTo to an unsaved record. When committing the transaction, I got two POST request. I don't know if I'm doing something wrong or not...
Here's my models and mapping:
Comment = App.Comment = DS.Model.extend({
title: DS.attr('string')
});
Group = App.Address = DS.Model.extend({
name: DS.attr('string')
});
Post = App.Post = DS.Model.extend({
title: DS.attr('string'),
comments: DS.hasMany(Comment),
group: DS.belongsTo(Group)
});
DS.RESTAdapte.map(Post, {
comments: { embedded: 'always' },
group: { embedded: 'always' }
});
My transaction
var transaction = store.transaction();
var post = transaction.createRecord(Post, {
title: 'This post is unsaved'
});
post.get('comments').createRecord({
title: 'This embedded record is also unsaved'
});
post.set('group', Group.createRecord({
name: 'My Group'
}));
transaction.commit();
Then I will have two POST request, one on '/post' wich is good and another one on '/group'.
Am I doing something wrong ? Thanks you !