I’m getting the next error when I’m trying to save a new record with an associated relationship. The problem I think is related to the creation of the record because ember doesn’t create any record.
Uncaught TypeError: Cannot call method 'save' of undefined
On the one hand, my models are the following (with a one-to-many relationship).
App.Kid = DS.Model.extend({
attribute1: DS.attr("string"),
parent: DS.belongsTo(parent)
});
App.Parent = DS.Model.extend({
attribute1: DS.attr("string"),
kids: DS.hasMany(kid)
});
On the other hand, my route is the following.
App.KidRoute = Ember.Route.extend({
model: function (id) {
var store = this.get('store');
store.find('usuario', id).then(function(parentmodel){
return this.store.createRecord('kid', {parent: parentmodel});
});
},
actions:{
save: function(){
this.get('currentModel').save();
}
}
});
Any help would be appreciate. Thanks!
Editing…
It is necessary to set the mapping on the adapter through embedded: 'always'
? Any thoughts?