diff options
author | guntasgrewal <guntasgrewal@gmail.com> | 2014-04-23 22:50:48 -0400 |
---|---|---|
committer | guntasgrewal <guntasgrewal@gmail.com> | 2014-04-23 22:50:48 -0400 |
commit | 41a93fad32677e3f351c0e16f0c704cbfbc5404e (patch) | |
tree | aa46c550dbd15a1f0bb0faf4e8eebb92c4970bdd /app/models | |
parent | 19b04a49d01af1917385c166501ef086eddae437 (diff) | |
parent | 47be7c86ca5193ffe4331fbb9358a9171abe748b (diff) |
Merge branch 'master' of https://github.com/LukeShu/leaguer
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/game.rb | 2 | ||||
-rw-r--r-- | app/models/remote_username.rb | 6 | ||||
-rw-r--r-- | app/models/tournament.rb | 1 | ||||
-rw-r--r-- | app/models/user.rb | 10 |
4 files changed, 15 insertions, 4 deletions
diff --git a/app/models/game.rb b/app/models/game.rb index 345877e..5f4c46d 100644 --- a/app/models/game.rb +++ b/app/models/game.rb @@ -1,3 +1,5 @@ class Game < ActiveRecord::Base + belongs_to :parent, class_name: "Game" + has_many :children, class_name: "Game" has_many :settings, class_name: "GameSetting" end diff --git a/app/models/remote_username.rb b/app/models/remote_username.rb index c2c3d20..8c1ce26 100644 --- a/app/models/remote_username.rb +++ b/app/models/remote_username.rb @@ -3,7 +3,11 @@ class RemoteUsername < ActiveRecord::Base belongs_to :user def value - JSON.parse(self.json_value) + begin + return JSON.parse(self.json_value) + rescue + return {} + end end def value=(v) diff --git a/app/models/tournament.rb b/app/models/tournament.rb index e21ccb1..686e066 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -40,6 +40,7 @@ class Tournament < ActiveRecord::Base end def []=(setting_name, val) + @tournament.save tournament_setting = @tournament.settings_raw.find_by_name(setting_name) if tournament_setting.nil? game_setting = @tournament.game.settings.find_by_name(setting_name) diff --git a/app/models/user.rb b/app/models/user.rb index 138f73e..5c0b5b1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -24,9 +24,13 @@ class User < ActiveRecord::Base end def find_remote_username(game) - obj = remote_username.where(:game => game) - if obj.nil? and not game.parent.nil? - return find_remote_username(game.parent) + obj = self.remote_usernames.where(:game => game).first + if obj.nil? + if game.parent.nil? + return nil + else + return find_remote_username(game.parent) + end else return obj.value end |