Tag: 相互友谊

rails activerecord,friend relation + inverse_friend关系如何获得相互关系? 代码包括在内

试图找到相互关系,在朋友关系中,已经有朋友和inverse_friends。 但如何将它们结合起来以获得共同的朋友呢? 似乎无法弄清楚我尝试了几个选项并在网上搜索了很长时间,只是看不到它 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 ?