Skip to content

Instantly share code, notes, and snippets.

@leokassio
Created August 26, 2021 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leokassio/5dd59cb32b44589e06eeb5e299d876c1 to your computer and use it in GitHub Desktop.
Save leokassio/5dd59cb32b44589e06eeb5e299d876c1 to your computer and use it in GitHub Desktop.
Sports App - Basic Data Model
class Tournament
has_many :matches, inverse_of: :tournament
has_many :teams, through: :matches, source: :teams
end
class Team
has_many :team_match_participations
has_many :matches, through: :team_match_participations, source: :match
has_many :players
end
class Match
has_many :team_match_participations
has_many :teams, through: :team_match_participations
belongs_to :tournament
end
class TeamMatchParticipation
belongs_to :team
belongs_to :match
end
@leokassio
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment