2017-01-11 3 views
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 

答えて

0

これを試してみてください:

followings: DS.hasMany('user', { inverse: 'followers' }, 
followers: DS.hasMany('user', { inverse: 'followings' },