I have the following table structure
manufacturers --> products ---> available_sizes_products :available_sizes_products has_many :available_sizes_products end class AvailableProductSize < ActiveRecord::Base belongs_to :sizes belongs_to :products end class Size < ActiveRecord::Base has_many :products, :through => :available_sizes_products has_many :available_sizes_products endI need to get a unique list of manufacturers, that have products in size "XL" or "L" for example.I'm getting lost in the chaining of joins etc.

class Manufacturer < ActiveRecord::Base def self.with_sizes(sizes=[]) @sizes = Sizes.find(sizes) ... endend Can someone help me with that ? Trying to do the Rails 4 way rather than drop down to SQL, since I need the query to run on several DBS
Thanks


Check Solution