I have a Product model that has_and_belongs_to_many :taxons, and I want to find all products that are in specific taxons.
Product
has_and_belongs_to_many :taxons
For example, if a pro
I had this problem a while back, thankfully there is a nice solution.
def self.has_taxons(taxons) id = arel_table[:id] Product.joins(:taxons).where(taxons: { name: taxons }).group(id).having(id.count.eq(taxons.size)) end