我有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應用程序,我知道這是找到途徑。什麼可能導致軌道找到適當的路線,但失敗的呼叫相關聯的行動。