From 730d6cbbde0baf14d918645363b2007e950c90bf Mon Sep 17 00:00:00 2001 From: Jared Cosulich Date: Fri, 10 Mar 2017 16:08:41 -0500 Subject: [PATCH] working on twilio integration --- app/controllers/attempts_controller.rb | 2 +- app/models/attempt.rb | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/controllers/attempts_controller.rb b/app/controllers/attempts_controller.rb index 2f93864a..f7fc4f81 100644 --- a/app/controllers/attempts_controller.rb +++ b/app/controllers/attempts_controller.rb @@ -3,7 +3,7 @@ class AttemptsController < ApplicationController protect_from_forgery :except => [:twilio] def twilio - attempt = Attempt.where(twilio_sid: params['MessageSid']).first + attempt = Attempt.where(twilio_sid: params['From']).first attempt.update_attributes( answer_index: params[:Body].to_i, twilio_details: params.to_h.to_yaml diff --git a/app/models/attempt.rb b/app/models/attempt.rb index 7d845eef..72d5f465 100644 --- a/app/models/attempt.rb +++ b/app/models/attempt.rb @@ -17,12 +17,8 @@ class Attempt < ApplicationRecord body: "#{question.text}\n\r#{question.option1}: Reply 1\n\r#{question.option2}: Reply 2\n\r#{question.option3}: Reply 3\n\r#{question.option4}: Reply 4\n\r#{question.option5}: Reply 5" ) - puts message.inspect - puts message.try(:path) - puts message.try(:sid) - # message.path.split('/').last - update_attributes(sent_at: Time.new, twilio_sid: message.sid) + recipient.update_attributes(phone: client.account.messages.get(message.sid).to) end end