你好,我找到了很多关于如何使用 LEFT OUTER JOIN 的示例,但我似乎无法找到访问我加入的内容的方法。这就是我的意思:
List.featured.
joins(
"LEFT OUTER JOIN follows ON (
follows.followable_id = lists.id AND
follows.followable_type = 'List' AND
follows.user_id = #{current_user.id})"
).map { |list|
list.follows # <-- returns all follows, not only the ones from current_user
...
在示例中,我通过加入得到以下(似乎),但是我怎样才能访问它们呢?这种follows
关系似乎会给我所有的关注。
或者,也许我的脑子里糊涂了:)谢谢!