add additional database table connecting game matches to participating players

This commit is contained in:
2026-11-10 01:04:07 +03:00
parent 271daac935
commit 219448ccfb
10 changed files with 103 additions and 3 deletions
+2
View File
@@ -4,6 +4,8 @@ class User < ApplicationRecord
has_many :sessions, dependent: :destroy
has_many :matches_as_player1, class_name: "Match", foreign_key: :player1_id, dependent: :restrict_with_exception, inverse_of: :player1
has_many :matches_as_player2, class_name: "Match", foreign_key: :player2_id, dependent: :restrict_with_exception, inverse_of: :player2
has_many :match_players, foreign_key: :player_id, dependent: :destroy, inverse_of: :player
has_many :matches, through: :match_players, source: :match
has_one_attached :avatar
normalizes :nickname, with: ->(n) { n.strip }