What about:
Category.find :all, :conditions => 'id in (select distinct category_id from categories_events)'
You can also add this as a named scope to your Category class so you can tell Category.with_events for example.
class Category < ActiveRecord::Base named_scope :with_events, :conditions => 'id in (select distinct category_id from categories_events)' end
mikej source share