简体   繁体   English

Resque - 未定义的方法'执行'为类

[英]Resque - undefined method 'perform' for class

I'm not having much luck with background queues at the moment. 我目前的背景队列运气不好。 I'm attempting to get Resque to work. 我正试图让Resque工作。 I've installed redis and the Resque gem. 我已经安装了redis和Resque gem。

Redis is running. Redis正在运行。 A worker is running (rake resque:work QUEUE=simple). 一个工人正在运行(rake resque:work QUEUE = simple)。 Using the web interface I can see that the worker is running and awaiting a job. 使用Web界面,我可以看到工作人员正在运行并等待工作。

When I run 'rake get_updates', the job is queued but fails. 当我运行'rake get_updates'时,作业排队但失败了。 I've tried it both with def self.perform and def perform. 我已经尝试过def self.perform和def perform。

clockwork.rake clockwork.rake

task :get_updates => :environment do
    Resque.enqueue(GetUpdates)
end

Class file (app/workers/get_updates.rb) 类文件(app / workers / get_updates.rb)

class GetUpdates
    @queue = :simple

    def perform

        puts "Running GetUpdates"

    end

end

Error Message 错误信息

undefined method `perform' for GetUpdates:Class
/Users/lukesmith/.rvm/gems/ruby-1.9.3-p327/bundler/gems/resque-620d354454b8/lib/resque/job_performer.rb:79:in `perform_job'
/Users/lukesmith/.rvm/gems/ruby-1.9.3-p327/bundler/gems/resque-620d354454b8/lib/resque/job_performer.rb:46:in `execute_job'
/Users/lukesmith/.rvm/gems/ruby-1.9.3-p327/bundler/gems/resque-620d354454b8/lib/resque/job_performer.rb:25:in `perform' 

perform method should be class instance method. perform方法应该是类实例方法。

class GetUpdates
  @queue = :simple

  def self.perform
    puts "Running GetUpdates"
  end

end

Did you try restarting resque after changing the method to self.perform. 在将方法更改为self.perform后,您是否尝试重新启动resque? Quit the rake resque and start again after changing the method name to self.perform. 退出rake resque并在将方法名称更改为self.perform后再次启动。 This should work for sure. 这应该是肯定的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM