According to my book (agile web development with rails 2nd ed)...
class Company < ActiveRecord::Base has_many :company_groups has_many :groups, :through => :company_groups has_many :groups_types, :through => :company_groups, :unique => true end
or
class Company < ActiveRecord::Base has_many :company_groups has_many :groups, :through => :company_groups has_many :groups_types, :through => :company_groups, :select => "distinct groups.*" end
Sorry about the timing, this group is too large to read daily.