2015-02-03 2 views
1

나는 계속 uninitialized constant Twilio::Rest 오류가 발생하며, 내가 잘못했는지 파악할 수 없습니다. 내 코드는 아래와 같습니다.초기화되지 않은 상수 Twilio :: Rest Rails

다이얼 모델

require 'twilio-ruby' 
class Dial < ActiveRecord::Base 
    before_create :send_call 

    private 

    def send_call 
     #begin 
      account_sid  = 'sid' 
      account_auth_token = 'auth' 
      caller = '+14693514939' 
      numbers = Number.find_by_sql('select phone from numbers') 

      @client = ::Twilio::Rest::Client.new account_sid, account_auth_token 

      numbers.each do |dial| 

       @client.account.calls.create(
         :from => caller, 
         :to => dial, 
         :url => 'http://twimlets.com/echo?Twiml=hello%20this%20is%20a%20test%20call%20please%20hang%20up&') 
      end 
     #rescue 
      #false 
     #end 
    end 
end 

내 전화보기

<%= button_to "Call", action: "create" %> 

어떤 아이디어?

답변

3

처음 일 수 있습니다. 시도 :

@client = Twilio::REST::Client.new account_sid, account_auth_token 

대신 예

@client = ::Twilio::Rest::Client.new account_sid, account_auth_token 

의 : https://github.com/twilio/twilio-ruby/blob/master/examples/examples.rb

또한 https://github.com/twilio/twilio-ruby/blob/master/lib/twilio-ruby/rest/client.rb를 참조 - REST는 대문자로 써야 것 같습니다.

+0

안녕하세요, 저는 Twilio의 개발자 전도사입니다. 여기서 머리에 못을 박았습니다.'Twilio :: Rest' 모듈은 없으며,'Twilio :: REST'로 대문자로 쓰여 있습니다. 점프와 응답 주셔서 감사! – philnash

+0

나는 이것을 스크립트에서 먼저 작성한 다음 레일로 넘겨 썼다. 내가 Twilio :: REST를 놓쳤다 고 생각하지 않는다. 고마워. –

관련 문제