diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/team_match_pair.rb | 4 | ||||
-rw-r--r-- | app/models/tournament.rb | 7 | ||||
-rw-r--r-- | app/models/tournament_user_pair.rb | 4 | ||||
-rw-r--r-- | app/models/user.rb | 4 | ||||
-rw-r--r-- | app/models/user_team_pair.rb | 4 | ||||
-rw-r--r-- | app/models/user_tournament_pair.rb | 4 |
6 files changed, 5 insertions, 22 deletions
diff --git a/app/models/team_match_pair.rb b/app/models/team_match_pair.rb deleted file mode 100644 index 85f8eaa..0000000 --- a/app/models/team_match_pair.rb +++ /dev/null @@ -1,4 +0,0 @@ -class TeamMatchPair < ActiveRecord::Base - belongs_to :team - belongs_to :match -end diff --git a/app/models/tournament.rb b/app/models/tournament.rb index c359b1c..44b22f5 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -1,8 +1,8 @@ class Tournament < ActiveRecord::Base belongs_to :game has_many :matches - has_many :user_tournament_pairs - has_many :users, :through => :user_tournament_pairs + has_and_belongs_to_many :players, class_name: "User", association_foreign_key: "player_id", join_table: "players_tournaments" + has_and_belongs_to_many :hosts, class_name: "User", association_foreign_key: "host_id", join_table: "hosts_tournaments" def open? return true @@ -16,8 +16,7 @@ class Tournament < ActiveRecord::Base unless joinable_by?(user) return false end - pair = UserTournamentPair.new(tournament: self, user: user) - return pair.save + players<<user end def setup diff --git a/app/models/tournament_user_pair.rb b/app/models/tournament_user_pair.rb deleted file mode 100644 index eb4e9c5..0000000 --- a/app/models/tournament_user_pair.rb +++ /dev/null @@ -1,4 +0,0 @@ -class TournamentUserPair < ActiveRecord::Base - belongs_to :tournament - belongs_to :user -end diff --git a/app/models/user.rb b/app/models/user.rb index bad7f7b..ff212e4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,6 +1,6 @@ class User < ActiveRecord::Base - has_many :user_tournament_pairs - has_many :tournaments, :through => :user_tournament_pairs + has_and_belongs_to_many :tournaments_played, class_name: "Tournament", foreign_key: "tournament_id", join_table: "players_tournaments" + has_and_belongs_to_many :tournaments_hosted, class_name: "Tournament", foreign_key: "tournament_id", join_table: "hosts_tournaments" before_save { self.email = email.downcase } before_save { self.user_name = user_name } diff --git a/app/models/user_team_pair.rb b/app/models/user_team_pair.rb deleted file mode 100644 index c55dc2e..0000000 --- a/app/models/user_team_pair.rb +++ /dev/null @@ -1,4 +0,0 @@ -class UserTeamPair < ActiveRecord::Base - belongs_to :user - belongs_to :team -end diff --git a/app/models/user_tournament_pair.rb b/app/models/user_tournament_pair.rb deleted file mode 100644 index b2676e5..0000000 --- a/app/models/user_tournament_pair.rb +++ /dev/null @@ -1,4 +0,0 @@ -class UserTournamentPair < ActiveRecord::Base - belongs_to :user - belongs_to :tournament -end |