LEFT OUTER joins in Rails 3

后端 未结 8 1978
自闭症患者
自闭症患者 2020-11-27 12:31

I have the following code:

@posts = Post.joins(:user).joins(:blog).select

which is meant to find all posts and return them and the associat

8条回答
  •  广开言路
    2020-11-27 13:19

    There is a left_outer_joins method in activerecord. You can use it like this:

    @posts = Post.left_outer_joins(:user).joins(:blog).select
    

提交回复
热议问题