试图找到相互关系,在朋友关系中,已经有朋友和inverse_friends。但如何结合他们获得共同的朋友?似乎无法弄清楚我试了几个选项,并在网上搜索很久,只是没有看到它rails activerecord,朋友关系+ inverse_friend关系如何获得相互关系?代码包括
has_many :friendships
has_many :friends, :through => :friendships
has_many :inverse_friendships, :class_name => "Friendship", :foreign_key => "friend_id"
has_many :inverse_friends, :through => :inverse_friendships, :source => :user
如何获得
has_many :mutual_friends ?
如果您发布的表会更容易解决您的问题线索定义,所以我们不必猜测你的模式。 –