Rails Joins and include columns from joins table

后端 未结 5 1212
小鲜肉
小鲜肉 2020-12-13 05:01

I don\'t understand how to get the columns I want from rails. I have two models - A User and a Profile. A User :has_many Profile (because users can revert back to an earlier

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 05:25

    Try using select("*").joins(:table)

    In this case, you would type:

    User.select("*").joins(:profile)
    

    Hope that works for you.

提交回复
热议问题