I am working on a development which has a number of many to many
relationships using link tables. I would like to find a way of finding
related records which share common attributes.
For example, a User has many Regions and an Event has many Regions.
My question is, what is the simplest way to link Users directly to the
Events that have Regions in common with them. The model files
contain…
Class User…
has_many :user_regions
has_many :regions, :through => :user_regions
…
Class Event…
has_many :event_regions
has_many :regions, :through => :event_regions
…
Class Region…
has_many :user_regions
has_many :users, :through => :user_regions
has_many :event_regions
has_many :events, :through => :event_regions
…
All suggestions appreciated. Thanks.
Dan