ruby - Rails - ArgumentError (wrong number of arguments (given 1, expected 0)): -
i'm trying receive sms twilio api. generated separate reply controller doesn't deal else in routes or resources. uses post method communicate twilio. im getting error:
"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 |r| r.message 'the robots coming! head hills!' end content_type 'text/xml' twiml.text end end here routes
rails.application.routes.draw resources :posts resources :phones resources :users root 'home#index' post "/reply/hart1" => "reply#hart1" end i'm under impression i'm routing improperly. heroku console gives me 500 error know it's fixable on end.
to send message 'twillio-ruby' code should this
# put own credentials here account_sid = 'acxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy' # set client talk twilio rest api @client = twilio::rest::client.new account_sid, auth_token # send sms message @client.api.account.messages.create( from: '+fromnumber', to: '+tonumber', body: 'the robots coming! head hills!' ) in controller like
require 'twilio-ruby' class replycontroller < applicationcontroller skip_before_action :verify_authenticity_token def hart1 send_text_message content_type 'text/xml' end private def send_text_message # put own credentials here account_sid = 'acxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy' # set client talk twilio rest api @client = twilio::rest::client.new account_sid, auth_token # send sms message @client.api.account.messages.create( from: '+fromnumber', to: '+tonumber', body: 'the robots coming! head hills!' ) end end the documentation 'twillo-ruby' here: https://github.com/twilio/twilio-ruby
Comments
Post a Comment