数日間問題が何であるかを理解しようとしてきましたが、うまくいきませんでした。Heroku Cedar で Rails 3.1.3 を Unicorn で実行し、バックグラウンド ジョブに Resque 1.20 を使用しています。
Redisアドオンが追加され、REDISTOGO_URLが設定され、resque.rb初期化子が
require 'resque'
Resque.after_fork = Proc.new { ActiveRecord::Base.establish_connection }
uri = URI.parse(ENV["REDISTOGO_URL"])
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
Resque.redis = REDIS
私も試しました
Resque.redis = Redis.connect(:url => ENV['REDISTOGO_URL'])
これも、公式RedisToGoサイトから
ENV["REDISTOGO_URL"] ||= "redis://username:password@host:1234/"
uri = URI.parse(ENV["REDISTOGO_URL"])
Resque.redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password, :thread_safe => true)
Heroku ワーカー:
bundle exec rake resque:work QUEUE='*'
すべてがローカルでも Heroku コンソールでも問題なく動作します。しかし、Railsからキューに入れようとすると
Resque.enqueue(EmailQueue, id)
私は得る
NoMethodError (undefined method `sadd' for nil:NilClass):
どうぞよろしくお願いいたします。