我在 Rails 中创建生成器时遇到问题,这是我遇到的错误。我正在尝试创建一个生成器,该生成器通过提供商 Twilio 创建 SMS 验证。
require "sms_auth-twilio"
NameError: uninitialized constant Twilio::Rails
from /Users/sherodtaylor/.rvm/gems/ruby-1.9.3-p125/gems/sms_auth-twilio-0.0.2/lib/sms_auth-twilio.rb:3:in `<module:Twilio>'
from /Users/sherodtaylor/.rvm/gems/ruby-1.9.3-p125/gems/sms_auth-twilio-0.0.2/lib/sms_auth-twilio.rb:2:in `<top (required)>'
from /Users/sherodtaylor/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
from /Users/sherodtaylor/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
from /Users/sherodtaylor/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
from (irb):1
from /Users/sherodtaylor/.rvm/rubies/ruby-1.9.3-p125/bin/irb:16:in `<main>'
这是我的代码
require "sms_auth-twilio/version"
module Twilio
class TwilioGenerator < Rails::Generator::Base
source_root File.expand_path("../generator", __FILE__)
def add_twilio_initializer
copy_file "twilio.rb", "config/initializer/twilio.rb"
end
# config info for the API
def twilio_config_info
copy_file "twilio.yml", "config/twilio.yml"
end
# Verification Controller to verify the company
def copy_verifications
copy_file "verifications_controller", "app/contoller/verifications_controller.rb"
end
end
end