title: Find Active Record object where multiple associations match (same field)
body: <p>For example, I have a <code>Product</code> and a <code>Favorite</code> association:</p>
  
  <pre><code>class Product &lt; ApplicationRecord
    has_many :favorites
  end
  class Favorite &lt; ApplicationRecord
    belongs_to :product
    belongs_to: user
  end
  class User &lt; ApplicationRecord
    has_many :favorites
  end
  </code></pre>
  
  <p>How could I find products that user with id <code>1</code> and user with id <code>2</code> have favorited? Even better, products that only those two users have favorited (nobody else has favorited it).</p>
  
  <p>I've tried joining multiple <code>where</code> queries, but that doesn't return any results. I've spent a solid while searching for an answer, but I'm really just hitting a wall.</p>
  
  <p>This was my latest attempt:</p>
  
  <pre><code>Product.includes(:favorites).where(favorites: { user_id: 1 }).where(favorites: { user_id: 2 })
  </code></pre>