summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/phone.rb6
-rw-r--r--app/models/phone_model.rb2
-rw-r--r--app/models/sip_account.rb2
3 files changed, 7 insertions, 3 deletions
diff --git a/app/models/phone.rb b/app/models/phone.rb
index a59b003..8b41b59 100644
--- a/app/models/phone.rb
+++ b/app/models/phone.rb
@@ -9,7 +9,7 @@ class Phone < ActiveRecord::Base
# Associations
#
belongs_to :phone_model
- belongs_to :phoneable, :polymorphic => true
+ belongs_to :phoneable, :polymorphic => true, :touch => true
has_many :phone_sip_accounts, :dependent => :destroy, :uniq => true, :order => :position
has_many :sip_accounts, :through => :phone_sip_accounts
@@ -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
diff --git a/app/models/phone_model.rb b/app/models/phone_model.rb
index e00e0e3..ac4d4a3 100644
--- a/app/models/phone_model.rb
+++ b/app/models/phone_model.rb
@@ -3,7 +3,7 @@ class PhoneModel < ActiveRecord::Base
# Associations
#
- belongs_to :manufacturer
+ belongs_to :manufacturer, :touch => true
has_many :phones, :dependent => :destroy
diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb
index 5388395..d35f9b4 100644
--- a/app/models/sip_account.rb
+++ b/app/models/sip_account.rb
@@ -10,7 +10,7 @@ class SipAccount < ActiveRecord::Base
# Associations:
#
- belongs_to :sip_accountable, :polymorphic => true
+ belongs_to :sip_accountable, :polymorphic => true, :touch => true
has_many :phone_sip_accounts, :uniq => true
has_many :phones, :through => :phone_sip_accounts