Reputation: 2528
Let's say I have Delivery
model which has one Postman
and that Postman
has many Team
s.
I would like to get all deliveries with specific team ID = 1 for example.
I have try:
Delivery.joins(:postman).where(:postmans => {team_ids: 1})
But I couldn't manage to get them. How can I achieve this?
Upvotes: 3
Views: 2945
Reputation: 33542
You should do like below
Delivery.joins(:postman => :teams).where(:postman => {teams: {id: 1}})
Upvotes: 5