不执行延迟作业

时间:2011-05-11 14:14:36

标签: ruby-on-rails ruby-on-rails-3 delayed-job

我正在使用collectiveidea中的delayed_job 2.1.4,即使处理并从队列中删除了作业,似乎也从未调用perform方法。我错过了什么吗?

我在Heroku上使用Rails 3.0.5

在控制器中:

Delayed::Job.enqueue FacebookJob.new

在Job类中:

class FacebookJob
  def initialize
  end

  def perform
    fb_auths = Authentication.where(:provider => 'facebook')
    fb_auths.each do |auth|
      checkins = FbGraph::User.new('me', :access_token => URI.encode(auth.token)).checkins
      if checkins != nil 
        checkins.each do |checkin|
          [...]
        end
      end
    end
  end
end

(整个代码:https://gist.github.com/966509

2 个答案:

答案 0 :(得分:1)

我遇到了同样的问题,这个答案对我有帮助:Delayed_job not executing the perform method but emptying the job queue

答案 1 :(得分:0)

简单的答案:DelayedJob是否了解Authentication和FBGraph :: User类?如果没有,您将完全看到您描述的行为:将从队列中静默删除项目。

  • 请参阅延迟作业Wiki中的this entry in the Delayed Job Wiki
  • 尝试在facebook_job.rb文件中添加'require authentication'和'require fb_graph'(或其他)。