Created
July 22, 2011 08:52
-
-
Save bjhaid/1099114 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
ruby code | |
1 require 'switchvox' | |
2 switchvox = Switchvox::Base.new("IP.com", 'admin', 'password', {:debug => true}) | |
3 dial = switchvox.request("switchvox.call", { | |
4 "dial_first" => "4600", | |
5 "dial_second" => "4100", | |
6 "dial_as_account_id" => "1122", | |
7 }) | |
8 calls = dial.calls.call | |
model without db switchvox_call.rb | |
1 require 'switchvox' | |
2 class Switchvox_call | |
def self.calling(cid_number) | |
3 switchvox = Switchvox::Base.new("IP.com", 'admin', 'password', {:debug => true}) | |
4 dial = switchvox.request("switchvox.call", { | |
5 "dial_first" => "4600", | |
6 "dial_second" => cid_number, | |
7 "dial_as_account_id" => "1122", | |
8 }) | |
9 calls = dial.calls.call | |
end | |
10 end | |
view call.html.erb | |
1 <%= form_tag(call_switchvox_path(:cid_number), :method => 'post') do %> | |
2 <%= text_field_tag "cid_number" %> | |
3 <%= submit_tag "Call" %> | |
4 <% end %> | |
controller incoming_controller.rb | |
1 require 'switchvox' | |
2 class IncomingsController < ApplicationController | |
3 # GET /incomings | |
4 # GET /incomings.xml | |
5 def index | |
6 @incoming = Incoming.all | |
7 #begin | |
8 #@contact = SugarCRM::Contact.find_by_phone_work(params[:cid_number]) || SugarCRM::Contact.find_by_phone_mobile(params [:cid_number]) || SugarCRM::Contact.find_by_phone_other(params[:cid_number]) | |
9 #rescue | |
10 #@contact = SugarCRM::Contact.find_by_phone_work(params[:cid_number]) || SugarCRM::Contact.find_by_phone_mobile(params [:cid_number]) || SugarCRM::Contact.find_by_phone_other(params[:cid_number]) | |
11 #end | |
12 | |
13 end | |
14 def create | |
15 @incoming = Incoming.create!(params[:incoming]) | |
16 end | |
17 | |
18 # GET /incomings/1 | |
19 # GET /incomings/1.xml | |
20 | |
21 def hangup | |
22 @switchvox = Incoming.first.exten_number | |
23 @switchvox_gem = Switchvox::Base.new("10.10.20.240", 'admin', 'Passw0rd', {:debug => true}) | |
24 @hangup = @switchvox_gem.request("switchvox.currentCalls.hangUp", { | |
25 "current_call_id" => @switchvox | |
26 }) | |
27 @hangup.calls.call | |
28 end | |
29 def call | |
30 Switchvox_call.calling(params[:cid_number]) | |
31 end | |
32 | |
33 end | |
backend | |
Started POST "/incomings/cid_number/call" for 127.0.0.1 at 2011-07-22 13:24:24 +0100 | |
Processing by IncomingsController#call as HTML | |
Parameters: {"utf8"=>"✓", "authenticity_token"=>"c7lbLCHMDYAj5Gxc3zEiI0MtlCkkU+wSiHvBB9a6gko=", "cid_number"=>"123", "commit"=>"Call", "id"=>"cid_number"} | |
Completed 500 Internal Server Error in 3948ms | |
NoMethodError (undefined method `gsub' for nil:NilClass): | |
app/models/switchvox_call.rb:5:in `calling' | |
app/controllers/incomings_controller.rb:30:in `call' | |
Rendered /home/abejide/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.9/lib/action_dispatch/middleware/templates/rescues/_trace.erb (6.2ms) | |
Rendered /home/abejide/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.9/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (45.4ms) | |
Rendered /home/abejide/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.9/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (71.1ms) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
undefined method
gsub' for nil:NilClass app/models/switchvox_call.rb:5:in
calling'app/controllers/incomings_controller.rb:30:in `call'