I am trying to add twilio to my rails app using the twilio gem and I am having issues. I first followed this tutorial https://www.twilio.com/docs/tutorials/walkthrough/appointment-reminders/ruby/rails#14 and did it in a separate app which works. However, when I moved it over to my main app its not working. I am not sure if it is because I don't have a specific route for twillio or what. Basically, I have an rsvp button on my site to rsvp to an event and I was hoping when the button is clicked it sends a text. Therefore, I put the code in the RSVP model. I am using delayed_jobs and when the button is clicked it is added to the delayed job queue. However, nothing is actually sent. Is there a way to look at logs for twilio? The code for the rsvp model is bellow. Thanks so much!!
require 'twilio-ruby'
class Rsvp < ApplicationRecord
belongs_to :user
belongs_to :event
validates :user_id, :uniqueness => { :scope => :event_id}
after_create :reminder
#
#
# @@REMINDER_TIME = 30.minutes # minutes before appointment
#
# def when_to_run
# time - @@REMINDER_TIME
# end
# Notify our appointment attendee X minutes before the appointment time
def reminder
@twilio_number = '+18888888888'
@client = Twilio::REST::Client.new ENV['TWILLIO_ACCOUNT'], ENV['TWILLIO_SECRET']
time_str = ((self.time).localtime).strftime("%I:%M%p on %b. %d, %Y")
reminder = "Hi #{self.event_id}. Just a reminder that you have an Event coming up in 30 minutes at #{time_str}."
message = @client.account.messages.create(
:from => @twilio_number,
:to => '+18888888888',
:body => reminder,
)
puts message.to
end
handle_asynchronously :reminder, :run_at => Proc.new { 1.minutes.from_now}
end