Created
August 12, 2009 20:25
-
-
Save jmazzi/166735 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CallLog < ActiveRecord::Base | |
def self.connect_db(extension) | |
# validate extension | |
npa = extension[1..3] | |
nxx = extension[4..6] | |
return self if self.table_name == "cdr_#{nxx}" | |
master = {"username"=>"root", "adapter"=>"mysql", "host"=>"localhost", "password"=>"", "database"=>"cdr_#{npa}"} | |
self.establish_connection(master) | |
self.set_table_name "cdr_#{nxx}" | |
self.set_primary_key "id" | |
self | |
end | |
end | |
module CallLogs | |
extend self | |
#@@cdr.add_method('get_cdrs', 'extension', 'limit', 'filter', 'start_date', 'end_date', 'start_value', 'additional', 'type', 'signup_date') | |
def find(extension, *args) | |
cdrs = CallLog.connect_db(extension) | |
conditions = { | |
}.merge(:accountcode => extension) | |
cdrs.find(:all, :conditions => conditions) | |
end | |
end | |
my_cdrs = CallLogs.find(15185558888) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment