1
我試圖實現「追隨者/追隨者」關係。Ember.Js Reflexive Association
應用/模板/ users.hbs ---------------------------
{{#each model as |user|}}
...
<button {{action 'follow' user}}>Follow</button>
{{/each}}
應用程序/路由/用戶.js ---------------------------
follow(user){
//currentUser is the one clicking on 'follow' button
//and it works.I can successfully alert it's properties.
currentUser.get('followings').pushObject(user);
},
app/models/user.js ------- ----------------
...
followings: DS.hasMany('user',{inverse: null}),
followers: DS.hasMany('user',{inverse: null}),
現在,此解決方案正在導致下面的錯誤;
Uncaught TypeError: Cannot read the property 'modelName' of undefined at assertPolymorphicType.notifyRecordRelationshipAdded