summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-03-06 21:31:18 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-03-06 21:31:18 -0500
commit64d4bd0d7bff0bf0e1c405bfa154f22775ca724e (patch)
tree1706940a8a104735bf5442190fb0aebc32f8d224 /app/models
parent5f8baf6334f427506193ea8efd1356812468e191 (diff)
use had_and_belongs_to_many
Diffstat (limited to 'app/models')
-rw-r--r--app/models/tournament.rb4
-rw-r--r--app/models/user.rb4
2 files changed, 4 insertions, 4 deletions
diff --git a/app/models/tournament.rb b/app/models/tournament.rb
index 26dec72..0510864 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", join_table: "tournaments_players"
+ has_and_belongs_to_many :hosts, class_name: "User", join_table: "tournaments_hosts"
def open?
return true
diff --git a/app/models/user.rb b/app/models/user.rb
index bad7f7b..0a226e5 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", join_table: "tournaments_players"
+ has_and_belongs_to_many :tournaments_hosted, class_name: "Tournament", join_table: "tournaments_hosts"
before_save { self.email = email.downcase }
before_save { self.user_name = user_name }