In ActiveRecord, has_many :through, and Polymorphic Associations, the OP\'s example requests ignoring the possible superclass of Alien
and Person
<
Have you tried the simplest thing - adding :conditions
to the has_many :through
s?
In other words, something like this (in widget.rb):
has_many :people, :through => :widget_groupings, :conditions => { :type => 'Person' }, :source => :grouper, :source_type => 'SentientBeing'
has_many :aliens, :through => :widget_groupings, :conditions => { :type => 'Alien' }, :source => :grouper, :source_type => 'SentientBeing'
JamesDS is correct that a join is needed - but it's not written out here, since the has_many :through
association is already doing it.