Filtering child objects in a has_many :through relationship in Rails 3

前端 未结 5 789
一个人的身影
一个人的身影 2021-02-01 19:23

Greetings,

I have an application where Companies and Users need to belong to each other through a CompanyMembership model, which c

5条回答
  •  野的像风
    2021-02-01 20:29

    How about something like this:

    Company.find(:id).company_memberships.where(:admin => true).joins(:user)
    

提交回复
热议问题