summaryrefslogtreecommitdiff
path: root/app/models/gateway.rb
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-01-20 20:57:35 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-01-20 20:57:35 +0100
commit4e67f8769a3a3199bfb5b363fe9baa231c329a2b (patch)
tree3479e67255b6612e1eca50245bb886680d305eb7 /app/models/gateway.rb
parenta2abe7dffb8fe31687910ca4be6dc0374a247d00 (diff)
Refactoring
Diffstat (limited to 'app/models/gateway.rb')
-rw-r--r--app/models/gateway.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/app/models/gateway.rb b/app/models/gateway.rb
index 21dc831..3e791a6 100644
--- a/app/models/gateway.rb
+++ b/app/models/gateway.rb
@@ -14,6 +14,7 @@ class Gateway < ActiveRecord::Base
:presence => true,
:inclusion => { :in => TECHNOLOGIES }
+ after_initialize :set_defaults
before_validation :downcase_technology
def to_s
@@ -25,4 +26,10 @@ class Gateway < ActiveRecord::Base
self.technology = self.technology.downcase if !self.technology.blank?
end
+ def set_defaults
+ if TECHNOLOGIES.count == 1
+ self.technology = TECHNOLOGIES.first
+ end
+ end
+
end