我正在尝试实施“追随者/追随者”关系。
应用程序/模板/ users.hbs ---------------------------
{{#each model as |user|}}
...
<button {{action 'follow' user}}>Follow</button>
{{/each}}
应用程序/路由/ users.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);
},
应用程序/模型/ 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
答案 0 :(得分:0)
试试这个:
followings: DS.hasMany('user', { inverse: 'followers' },
followers: DS.hasMany('user', { inverse: 'followings' },