次の 2 つのモデルから関連付けられた関係を持つ新しいレコードを作成しようとしています。
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)
});
そして、私のルートは次のとおりです。フォームを介して属性の新しい値でモデルを保存するために、テンプレートでアクション ハンドラーも使用しています。
App.KidRoute = Ember.Route.extend({
model: function (id) {
return this.store.createRecord('kid', {parent: id});
},
actions:{
save: function(){
this.get('currentModel').save();
}
}
});
しかし、私はこのエラーが発生しています。
Assertion failed: You can only add a 'parent' record to this relationship
私は何か間違ったことをしていることを知っていますがparent
、属性だけで属している関係ではない場合に機能します。しかし、私はこれを望んでいません。
ありがとうございます!