Twillio Rails没有发送

时间:2017-04-22 16:42:45

标签: ruby-on-rails twilio twilio-api twilio-click-to-call

我正在尝试使用twilio gem将twilio添加到我的rails应用程序中,我遇到了问题。我首先按照本教程When i tried to add the values in comboBox 并在一个单独的应用程序中工作。但是,当我把它移到我的主应用程序时,它无法正常工作。我不确定是不是因为我没有特定的twillio途径或什么。基本上,我在我的网站上有一个rsvp按钮来rsvp到一个事件,我希望当点击按钮时它发送一个文本。因此,我把代码放在RSVP模型中。我正在使用delayed_jobs,当单击该按钮时,它将被添加到延迟的作业队列中。但实际上并没有发送任何内容。有没有办法查看twilio的日志? rsvp模型的代码如下。非常感谢!!

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

0 个答案:

没有答案