我試圖從twilio API接收短信。我生成了一個單獨的回覆控制器,它不處理我的路由或資源中的任何其他內容。它使用post方法與twilio進行通信。即時得到錯誤:Rails - ArgumentError(錯誤的參數數量(給出1,預期0)):
"ArgumentError (wrong number of arguments (given 1, expected 0)):"
replycontroller.rb
class ReplyController < ApplicationController
require 'twilio-ruby'
skip_before_action :verify_authenticity_token
def hart1
twiml = Twilio::TwiML::Response.new do |r|
r.Message 'The Robots are coming! Head for the hills!'
end
content_type 'text/xml'
twiml.text
end
end
這裏是我的路線
Rails.application.routes.draw do
resources :posts
resources :phones
resources :users
root 'home#index'
post "/reply/hart1" => "reply#hart1"
end
我的感覺,我不當這個路由下。 Heroku控制檯也給了我一個500錯誤,所以我知道這是我可以修復的東西。
我不是很確定,但根據[THIS](https://www.twilio.com/docs/quickstart/ruby/sms/hello-monkey)文檔,您可以嘗試'r.message(body :「機器人來了!去山頭!」)' – Abhi
另外,我覺得'r.Message'應該是'r.message'(小寫)[REF](https://www.twilio.com/ docs/guides/how-to-receive-and-reply-in-ruby) – Abhi
您使用的是哪個版本的Ruby庫? – philnash