After spending a few days of trying to find an answer online, I figured I should ask for help. I'm trying to figure out the best way to implement these relationships using Rails Associations.
I have 4 models: User
, Transfer
, Building
and Bag
.
A User
has a role
attribute. The possible values for role
are 'admin'
, 'building_contact'
and 'guest'
.
This is what it looks like in a tree structure. The Admin
, Guest
and BuildingContact
is the role of a @user
:
Admin | Transfer / \ Guest Building | | Bag BuildingContact
Therefore:
Admin has_many :transfers
Transfer belongs_to :admin
Transfer has_many :guests
Guest belongs_to :transfer
Guest has_many :bags
Transfer belongs_to :building
Building has_many :transfers
Building has_many :building_contacts
What is the best way to implement the relationship with the User
model?
Thanks in advance!