现在我想我明白你想要做什么,这就是我将如何建模:
User
:
has_many :friends
has_many :person_interests, :as => :person
has_many :interests, :through => :person_interests
has_many :user_holidays
has_many :holidays, :through => :user_holidays
Friend
:
belongs_to :user
has_many :person_interests, :as => :person
has_many :interests, :through => :person_interests
PersonInterest
:
belongs_to :interest
belongs_to :person, :polymorphic => true
Interest
:
has_many :person_interests
has_many :people, :through => :person_interests # may need an `inverse_of` here
UserHoliday
:
belongs_to :user
belongs_to :holiday
Holiday
:
has_many :user_holidays
has_many :users, :through => :user_holidays
通过这些设置,您应该能够执行您需要执行的查询。