Is it possible to make scope in Rails with where IN (?) query, which will check exact matches?
where IN (?)
for example:
Post.joins(:tags).where(\'ta
The idea to get matching all values in IN clause you have to do this:
IN
tag_ids = [1, 2, 3, 4] Post.joins(:tags).where('tags.id IN (?)', tags_ids).group("posts.id") .having("COUNT(posts.id) >= ?", tag_ids.length)
I hope this help you.