我的 gemfile 中有以下行并做了一个bundle install
:
gem 'twilio-ruby'
我有以下基于 twilio-ruby gem 示例的代码:
class TwilioEntriesController < ApplicationController
def process_message
# init client
@account_sid = 'REMOVED'
@auth_token = 'REMOVED'
@from_number = '+14159675278'
@client = Twilio::REST::Client.new(@account_sid, @auth_token)
# send response
@client.account.sms.messages.create(
:from => @from_number,
:to => '+REMOVED',
:body => 'Hey there!'
)
render :result, :layout => ''
end
end
我得到的错误是:
uninitialized constant TwilioEntriesController::Twilio
Ruby 似乎正在“TwilioEntriesController”中寻找“Twilio”类,这是调用的来源。它应该从正确的类(“Twilio”)中调用该方法-给出了什么?
如何按照 twilio-ruby 文档的描述在 Twilio 类上调用静态方法?