summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/route_element.rb2
-rw-r--r--app/models/sip_account.rb7
2 files changed, 7 insertions, 2 deletions
diff --git a/app/models/route_element.rb b/app/models/route_element.rb
index 94f0f84..7d37db0 100644
--- a/app/models/route_element.rb
+++ b/app/models/route_element.rb
@@ -3,7 +3,7 @@ class RouteElement < ActiveRecord::Base
attr_accessible :call_route_id, :var_in, :var_out, :pattern, :replacement, :action, :mandatory, :position
- belongs_to :call_route
+ belongs_to :call_route, :touch => true
acts_as_list :scope => :call_route
diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb
index 3340a76..1ff3c9a 100644
--- a/app/models/sip_account.rb
+++ b/app/models/sip_account.rb
@@ -38,7 +38,8 @@ class SipAccount < ActiveRecord::Base
has_many :ringtones, :as => :ringtoneable, :dependent => :destroy
- has_many :calls, :finder_sql => lambda { |s| "SELECT DISTINCT calls_active.* FROM calls_active WHERE sip_account_id = #{self.id} OR b_sip_account_id = #{self.id}" }
+ has_many :call_legs, :class_name => 'Call'
+ has_many :b_call_legs, :class_name => 'Call', :foreign_key => 'b_sip_account_id'
# Delegations:
#
@@ -83,6 +84,10 @@ class SipAccount < ActiveRecord::Base
def to_s
truncate((self.caller_name || "SipAccount ID #{self.id}"), :length => GsParameter.get('TO_S_MAX_CALLER_NAME_LENGTH')) + " (#{truncate(self.auth_name, :length => GsParameter.get('TO_S_MAX_LENGTH_OF_AUTH_NAME'))}@...#{self.host.split(/\./)[2,3].to_a.join('.') if self.host })"
end
+
+ def calls
+ self.call_legs + self.b_call_legs
+ end
def call_forwarding_toggle( call_forwarding_service, to_voicemail = nil )
if ! self.phone_numbers.first