[Rails] Many to Many and Related Records
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
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home