I was wondering if someone could help me model the below scenario. I have a User class, an Event class and a Venue class in Mongoid. I would like for users to be admins of either an Event or a Venue or both. These different roles could end up spiraling out of control and I was wondering if this would be an good case for polymorphism.
Venue
has_and_belongs_to_many :admins, :class_name=> 'User', :inverse_of=>:venue_adminships
has_and_belongs_to_many :managers, :class_name=> 'User', :inverse_of=>:venue_managementships
Event
has_and_belongs_to_many :admins, :class_name=> 'User', :inverse_of=>:event_adminships
has_and_belongs_to_many :managers, :class_name=> 'User', :inverse_of=>:event_managementships
User
has_and_belongs_to_many :venue_adminships, :class_name=>"Venue", inverse_of: :admins
has_and_belongs_to_many :venue_managementships, :class_name=>"Venue", inverse_of: :managers
has_and_belongs_to_many :event_adminships, :class_name=>"Event", inverse_of: :admins
has_and_belongs_to_many :event_managementships, :class_name=>"Event", inverse_of: :managers
I need to be able to pull up a User's "adminships" (while I'm at it, anyone have a better name than "adminship".... ? ) as well as pull up all the admins for an Event. What would be a cleaner way to represent this without so many repeating relationships?