我无法使用amistad gem返回所有阻止您的个人资料。
我能够找到您阻止的个人资料。
其他个人资料的个人资料已被屏蔽。
a = Profile.find_by_id 6
b = Profile.find_by_id 7
b.block_profile a
a.blockades
Profile Load (0.2ms) SELECT ".."
=> #<ActiveRecord::Associations::CollectionProxy [#<Profile id: 18....>]>
a.blockades_by
Profile Load (0.2ms) SELECT "profiles".* FROM "profiles" INNER JOIN "friendships" ON "profiles"."id" = "friendships"."friendable_id" WHERE "friendships"."blocker_id" = ? AND (friendable_id <> blocker_id) [["blocker_id", 6]]
=> #<ActiveRecord::Associations::CollectionProxy []>
b.blockades
Profile Load (0.2ms) SELECT "...."
=> #<ActiveRecord::Associations::CollectionProxy [#<Profile id: 6,....>]>
Oky, so it works if you know which profile exactly to look at.
但问题是我需要遍历每个配置文件并查看其blockades_by以查看登录用户是否存在,然后从最终查询中删除它们。这太疯狂了。需要一种更简单的方法吗?