我有Twilio的付费帐户。在我的Rails应用程序中,我有一个非常简单的设置,可以用twilio来接听来电。在routes.rb
,我有Rails没有路由到我的Twilio控制器动作
post 'communications/answer_phone' => 'communications#answer_phone'
在communications_controller.rb
,我有
class CommunicationsController < ApplicationController
skip_before_action :verify_authenticity_token
def answer_phone
logger.debug '******** answered'
response = Twilio::TwiML::Response.new do |r|
r.Say "Yay! You’re on Rails!", voice: "alice"
end
render :xml => response.to_xml
end
end
如果我尝试打电话给我Twilio号,ngrok说500 Internal Server Error
,所以我知道的要求越来越来ngrok。如果我看我的轨道日志文件,我看到
Started POST "/communications/answer_phone" for xxx.xxx.xxx.xxx at 2017-02-02 21:47:06 +1100
因此,请求被做它对我的申请。我的日志文件logger.debug
中没有******** answered
。该请求永远不会对我的answer_phone
操作产生影响。任何想法可能是错的?
UPDATE
我已经做了rake routes
这给了我
communications_receive_sms POST /communications/answer_phone(.:format) communications#answer_phone
这看起来是正确的。如果我故意在routes.rb
拼写不正确的路线,我得到这个错误
ActionController::RoutingError (No route matches [POST] "/communications/answer_phone"):
所以我知道的要求越来越到我的Rails应用程序,我知道这是找到途径。什么可能导致轨道找到适当的路线,但失败的呼叫相关联的行动。