活动记录,其中外键可以是两列中的任何一个

问题描述

| 我有一个用户模型。 我有一个Friend模型,其中包含columne_id和Inviter_id和状态列。无论是否接受好友请求,状态均用作标记。 Inviter_id是发送朋友请求的用户的ID,inviter_id是正在接收朋友请求的用户的。请检查嵌入式注释。
class User < ActiveRecord::Base
    has_many :friends // now i want to search all the friends with accepted friend request. (sent or received both.)
    has_many :pending_friend_requests,:class_name => \"Friend\",:foreign_key=>\"invitee_id\",:conditions => {:status => 0}
end

class Friend < ActiveRecord::Base

end
问题是如何获取所有已接受好友请求的好友..因为有两个外部列,所以已发送或接收。邀请对象编号或邀请对象编号     

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)