我是新手,对于Ruby和Ruby on Rails还不熟悉,现在想设置Twilio发送短信。
到目前为止,在我的Rails应用程序中有以下代码:当我尝试发送短信时,出现以下错误:
Missing template twilio/send_text_message, application/send_text_message with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :slim, :coffee, :haml]}.
我的初始化程序
#config/initializers/twilio.rb (removed keys)
require 'twilio-ruby'
account_sid = "XXXXXXXXX"
auth_token = "XXXXXXX"
$twilio_phone_number = "+XXXXXXXXXX"
$twilio_client = Twilio::REST::Client.new account_sid, auth_token
然后在路由中添加。
#routes.rb
post 'twilio/send_text_message' => 'twilio#send_text_message'
然后我有我的Twilio控制器
#twilioController
class TwilioController < ApplicationController
def index
end
def send_text_message
end
end
在我看来,我已经设置了一个表单让用户输入一条消息并将其发送到我的手机(因为我处于试用模式并且已验证)。
#ShareWithWorld.html.slim
= form_for :twilio, url: '/twilio/send_text', method: :post do |f|
=f.text_field "Hey"
=f.submit "Send Text"
root_path
不是发送文本消息的操作。 - Brandon Cordell