我正在开发一个类似于Michael Hartl的Railstutorial的示例应用程序,并希望显示当前用户不的所有用户。我怎么能这样做?
User.rb是:
has_many :following_relationships, class_name: "Relationship", foreign_key: :follower_id
has_many :leading_relationships, class_name: "Relationship", foreign_key: :leader_id
Relationship.rb是:
belongs_to :follower, class_name: "User"
belongs_to :leader, class_name: "User"
答案 0 :(得分:0)
这会有用吗?
@followingusers =您所关注的用户所拥有的一切
@notfollowingusers = User.where(“id not in(?)”,@ followingusers.map(&:id))