Multiple joins to the same model using multiple belongs_to associations
问题 I have a class Agreement that has two belongs_to associations to a Member class - referenced as primary and secondary: class Agreement < ActiveRecord::Base belongs_to :primary, class_name: 'Member' belongs_to :secondary, class_name: 'Member' ... def self.by_member(member_attribute_hash) # returns any agreements that has a primary OR secondary member that matches any of the values # in the member_attribute_hash ... end end The Member class has no knowledge of the association with the Agreement