summaryrefslogtreecommitdiff
path: root/app/models/sip_account.rb
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-03-07 11:25:33 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-03-07 11:25:33 +0100
commit846c6ca704e587621eab0c373693c4f52e4c8433 (patch)
tree92ee4468bc1b91045027055191bdc183adf5cd4b /app/models/sip_account.rb
parent88785c0ca2189c47b0a994473ef73a542ed36688 (diff)
Added a different VIEW definition for sqlite3 and refactored some has_many
code for the sip_account.
Diffstat (limited to 'app/models/sip_account.rb')
-rw-r--r--app/models/sip_account.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb
index 81b9c1c..cdb609d 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