Reputation: 5735
How do I convert this to more of more AR friendly where clause?
relation.where("users.id = (?)", user_id)
end
I tried
relation.where(id: ?, user_id)
but I need to specify the table since the AR has multiple joins.
As I want to be able to provide just a single user_id or an array of user_ids.
Upvotes: 0
Views: 46
Reputation: 20263
It seems a little hard to say with so little information. But, have you tried:
relation.where(users: {id: user_id})
user_id
can be an integer, an array of ids, an enumerable of users, etc.
Upvotes: 3