lundi 16 novembre 2015

Rails scope - where in strict

Is it possible to make scope in Rails with where IN (?) query, which will check exact occurrence to the array?

for example:

Post.joins(:tags).where('tags.id IN (?)', [1, 2, 3, 4])

will find posts with tags 1, 2, 1, 2, 3 and 1, 2, 3, 4. But should find only post with 1, 2, 3, 4 tags.

Aucun commentaire:

Enregistrer un commentaire