I'm a complete RoR newbie, and am working on a project involving games.
Each game involves two teams, and I'm trying to figure out how best to
set this up in the model.
Here is a snippet from my tables:
GAMES table:
game_id
home_team_id
away_team_id
TEAMS table:
team_id
name
Each game is represented by a single record in the Games table. Each
team is represented by a single record in the Teams table. Each game
has a home team and an away team.
The home_team_id and away_team_id fields both refer to the Teams table.
If there was only one team, the end product would be easy, but since I
have two different fields in the Game table that refer back to the same
validation table, I'm struggling.