开发者

Help installing delayed_job

I'm trying to use collectiveidea's delayed_job gem The installation instructions include

Rake tasks are not automatically loaded from gems,开发者_StackOverflow中文版 so you’ll need to add
the following to your Rakefile:

begin
  require 'delayed/tasks'
rescue LoadError
  STDERR.puts "Run `rake gems:install` to install delayed_job"
end

Where is my Rakefile? And what is a Rakefile?


I had the same problem with rails 3.1 and collectiveidea-delayed_job.

Once I added Delayed::Worker.backend = :active_record in the initializer I got the error
no such file to load -- delayed/backend/active_record (LoadError)

The solution for me was to add gem 'delayed_job_active_record' in the gemfile, as suggested here


I have the same problem and put that code in delayed_job.rake in the lib/tasks directory. It works, but now It say's:

*** Starting job worker localhost pid:79949 
rake aborted! 
uninitialized constant Delayed::Job

What is wrong now?

UPDATE: I just got a mail answer from Brandon:

Theres a bug in the latest version where it doesn't get properly initialized when using the rake task. If you create a file in config/initializers and put the follow in it, the error should go away:

Delayed::Worker.backend = :active_record


The Rakefile is a file that is used to configure rake, a Ruby build tool (sort of like make, but all in Ruby). In a Rails project, there is a file in the top project directory named Rakefile where you can insert this code.

Alternatively, you can add a file into the lib/tasks directory (for example named delayed_job.rake) and put the code into there. The name of the file is not important as long as

  1. It is in the lib/tasks directory
  2. It has the extension .rake
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜