2 Way Friendship between different models
Ruby on Rails App. I have two kinds of users,
Company
has_many :employees #sample
Employee
has_one :company
I want to create friendships between these two models, keeping track of the requester of the relationship (.requested_relationships) and the receiver (.pending-relationships) as well as the status (accepted, pending, etc). I can easily create the relationship with a third model and has_many :through ... BUT that wouldn't allow me to track who initiated the relat开发者_如何学Pythonionship and thus distinguish between pending and requested relationships. What is the correct way to model this? I've been playing around with a polymorphic attribute on the relationship model, but without concrete success.
you can try to use amistad gem
very good for friendship relationship and has a very good documentation that can help you out alot. just check it out
精彩评论