sql - Active Record query to match every subset element -


In my ROR application, I am looking for such a database:

  .jenx (: Products) .where ({'product.id' => [1,2,3]}) Unfortunately this will return all the customers who purchased the product. There are 1, 2 or 3 but I only want to get back the customers who bought  all  of three products, I would like to write a question that matches the n elements for a set Does.  

Is there any great solution for this?

more dynamic way the answer is

  id = [1, 2,3] Client.Junks (: Products). Where ({'products.id' =>;}} group ('users.id'). ('COUNT (DISTINCT products.id)> =' ', ids.size)  

Comments