I can’t seem to get my head wrapped around how to do this. I have the
following model:
class Match < ActiveRecord::Base
has_one :winning_team, :class_name => “Team”
has_one :losing_team, :class_name => “Team”
has_one :submitter, :class_name => “User”
has_one :Approver, :class_name => “User”
has_many :games
end
Basically it has 2 Teams and 2 Users. I’m not sure what
to do with the belongs_to: for Team and User since they could
belong with a foreign_key of winning_team or losing_team and submitter
or approver respectively. What is the best way to model a situation
where
you have multiple keys referencing the same table?