diff options
author | Luke Shumaker <shumakl@purdue.edu> | 2014-04-29 03:41:21 -0400 |
---|---|---|
committer | Luke Shumaker <shumakl@purdue.edu> | 2014-04-29 03:41:21 -0400 |
commit | f9488b183bbd41d74d801a9cbdd41410be4ddba5 (patch) | |
tree | a485cfd89181c447a3f471dacdfdf6bc57c823dd /app/models/tournament_setting.rb | |
parent | cd0c7d73be76feffbaaea9200c485b2316604469 (diff) |
Validate everything that I can.
Diffstat (limited to 'app/models/tournament_setting.rb')
-rw-r--r-- | app/models/tournament_setting.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/models/tournament_setting.rb b/app/models/tournament_setting.rb index 9efaaea..20d9842 100644 --- a/app/models/tournament_setting.rb +++ b/app/models/tournament_setting.rb @@ -1,6 +1,18 @@ class TournamentSetting < ActiveRecord::Base belongs_to :tournament + validates(:vartype, presence: true, numericality: {only_integer: true}) + validates(:type_opt, presence: true, if: :needs_type_opt?) + + def needs_type_opt? + [ + GameSetting.types[:pick_one_radio], + GameSetting.types[:pick_one_dropdown], + GameSetting.types[:pick_several], + ].include? self.vartype + end + + def self.types GameSetting.types end |