summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-01-12 10:53:20 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-01-12 10:53:20 +0100
commit2e3bddd415f03aa15cd2759d7c18f64d5545ea80 (patch)
treea684e7bc666b81eeef8f93b924b10f1a65de7ee0 /app/models
parentd8287a7dbcc287791ed069cfc14ca6b9db0e66a7 (diff)
Accept truncated MAC addresses. #80
Diffstat (limited to 'app/models')
-rw-r--r--app/models/phone.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/app/models/phone.rb b/app/models/phone.rb
index a59b003..4865a12 100644
--- a/app/models/phone.rb
+++ b/app/models/phone.rb
@@ -200,6 +200,10 @@ class Phone < ActiveRecord::Base
# Sanitize MAC address.
#
def sanitize_mac_address
+ if self.mac_address.split(/:/).count == 6 && self.mac_address.length < 17
+ splitted_mac_address = self.mac_address.split(/:/)
+ self.mac_address = splitted_mac_address.map{|part| (part.size == 1 ? "0#{part}" : part)}.join('')
+ end
self.mac_address = self.mac_address.to_s.upcase.gsub( /[^A-F0-9]/, '' )
end