I want to grab all the categories that contain purchaseable products.
products
class Product < ActiveRecord::Base belongs_to :category scope :purchase
You should use the merge method
class Category < ActiveRecord::Base has_many :products scope :with_purchaseable_products, joins(:products).merge(Product.purchaseable).group(:id).having('count(products.id) > 0') end
Read more on http://asciicasts.com/episodes/215-advanced-queries-in-rails-3