未初始化常量 Twilio::Rest Rails

uninitialized constant Twilio::Rest Rails

我一直收到 uninitialized constant Twilio::Rest 错误,无法弄清楚我做错了什么。我的代码如下。

表盘型号

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" %>

有什么想法吗?

可能是第一个 :: 扔掉它。尝试:

@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 看起来应该大写。