Class Match < ActiveRecord::Base belongs_to :winning_team, :class_name => "Team", :foreign_key => "winner_id" belongs_to :losing_team, :class_name => "Team" , :foreign_key => "loser_id" beongs_to :submitter, :class_name => "User", :foreign_key => "submitter_id" belongs_to :Approver, :class_name => "User", :foreign_key => "approver_id" has_many :games end
Table should look like this: id winner_id loser_id submitter_id approver_id <additonal fields>
the other classes:
class User < ActiveRecord::Base has_many :submitted_matches, :class_name => "Match", :foreign_key => "submitter_id" has_many :approved_matches, :class_name => "Match", :foreign_key => "approver_id end
class Team < ActiveRecord::Base has_many :won_games, :class_name => "Match", :foreign_key => "winner_id" has_many :lost_games, :class_name => "Match", :foreign_key => "loser_id" end
something like that ...