Aden Handasyde
Aden Handasyde

Reputation: 61

Parent has_many children, find parents containing child

Postadmins.where(users: current_user)

This isn't going to work, but it shows what I'm looking for. A post admin has many users, but I'm looking for all postadmins that 'contains' or 'includes' at least the one particular user.

Upvotes: 0

Views: 61

Answers (1)

Vasilisa
Vasilisa

Reputation: 4640

You should join users table, try this:

Postadmin.joins(:users).where(users: { id: current_user.id } )

Upvotes: 1

Related Questions