質問

I'm using sidekiq and twilio to send a text at a specified time.

My message_worker.rb contains the following:

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

My redis.rb contains the following:

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

I am getting the following error message (I've spaced it for ease of reading):

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'
役に立ちましたか?

解決

I needed to set my credentials that are inside of the ENV file. The format is as follows:

heroku config:set GITHUB_USERNAME=joesmith

You can also check out heroku's information on configuration variables (config vars): config vars on heroku

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top