Consider the following associations:
class User < ActiveRecord::Base
has_many :messages, :foreign_key => "publisher_id"
scope :wrote_at_least_one_message, <??>
end
class Message < ActiveRecord::Base
belongs_to :publisher, :class_name => "User"
end
How could I implement the wrote_at_least_one_message named scope ?
How about this? The inner join would check for at least one entry in messages table. Distinct is to avoid duplicates.