Sidekiq Twilio Redis'未定义的方法`strip'为nil:NilClass'

时间:2014-04-21 17:51:24

标签: ruby-on-rails redis twilio sidekiq

我使用sidekiq和twilio在指定时间发送文本。

我的message_worker.rb包含以下内容:

class MessageWorker
  include Sidekiq::Worker

  sidekiq_options retry: false

  sidekiq_retries_exhausted do |msg|
    Sidekiq.logger.warn "Failed #{msg['class']} with #{msg['args']}: #{msg['error_message']}."
  end

  def perform(id)
    record = Textmessage.find id
    @twilio = Twilio::REST::Client.new ENV['ACCOUNT_SID'], ENV['AUTH_TOKEN']

    @twilio.account.messages.create(
      from: ENV['ACCOUNT_PHONE_NUMBER'],
      to: record.phone_number,
      body: 'This is your scheduled reminder to view a house.'
    )
  end
end

我的redis.rb包含以下内容:

uri = URI.parse(ENV["REDISTOGO_URL"])
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)

我收到以下错误消息(为了便于阅读,我将其间隔开来):

Completed 200 OK in 245ms (Views: 180.7ms | ActiveRecord: 46.6ms)

2014-04-21T17:... 

MessageWorker JID-... INFO: fail: 0.497 sec

2014-04-21T17:04:57.636194+00:00 app[web.1]:...

 WARN: {"retry"=>false, "queue"=>"default", "class"=>"MessageWorker", "args"=>[5], 

"jid"=>"...", "enqueued_at"=>...}

2014-04-21T17:04:57.636194+00:00 app[web.1]: 2014-04-21T17:04:57Z 5 TID-...

 **WARN: undefined method `strip' for nil:NilClass**

2014-04-21T17:04:57.637073+00:00 app[web.1]: 2014-04-21T17:04:57Z 5 TID-...

WARN: /app/vendor/bundle/ruby/2.0.0/gems/twilio-ruby-3.11.5/lib/twilio-
ruby/rest/client.rb:142: in `initialize'

1 个答案:

答案 0 :(得分:0)

我需要设置ENV文件中的凭据。格式如下:

heroku config:set GITHUB_USERNAME=joesmith

您还可以查看heroku关于配置变量(配置变量)的信息:config vars on heroku