I have a model, called Procedure
which has to be owned by a user and assigned to another user. I have a single table User, with roles to distinguish users.
So a procedure has 2 references to the table User.
I found and implemented this solution here so in my Procedure model I have
belongs_to :owner, class_name: "User", foreign_key: "owner_id"
belongs_to :assignee, class_name: "User", foreign_key: "assignee_id"
and in model User I have this
has_many :owned_procedures, class_name: "Procedure", foreign_key: "owner_id"
has_many :assigned_procedures, class_name: "Procedure", foreign_key: "assignee_id"
but I cannot understand how this physically should be implemented, I mean at table level:
does table procedures
need to have both the fields owner_id and assignee_id
, or just a field user_id
?