帮助安装delayed_job

发布于 2024-08-28 06:44:58 字数 337 浏览 10 评论 0 原文

我正在尝试使用collectiveidea的delayed_job gem 安装说明包括

Rake tasks are not automatically loaded from gems, 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

我的 Rakefile 在哪里?什么是 Rakefile?

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

Rake tasks are not automatically loaded from gems, 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

江心雾 2024-09-04 06:44:58

我对rails 3.1和collectiveidea-delayed_job也有同样的问题。

在初始化程序中添加 Delayed::Worker.backend = :active_record 后,我收到错误
没有这样的文件来加载 --delayed/backend/active_record (LoadError)

对我来说,解决方案是在 gemfile 中添加 gem 'delayed_job_active_record',如建议的此处

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

相思碎 2024-09-04 06:44:58

我有同样的问题,并将该代码放在 lib/tasks 目录中的elasted_job.rake 中。它有效,但现在它说:

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

现在出了什么问题?

更新:我刚刚收到布兰登的邮件答复:

最新版本中存在一个错误,在使用 rake 任务时它无法正确初始化。如果您在 config/initializers 中创建一个文件并将以下内容放入其中,则错误应该消失:

Delayed::Worker.backend = :active_record

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
濫情▎り 2024-09-04 06:44:58

Rakefile 是一个用于配置rake,一个 Ruby 构建工具(有点像 make,但全部用 Ruby 编写)。在 Rails 项目中,顶部项目目录中有一个名为 Rakefile 的文件,您可以在其中插入此代码。

或者,您可以将文件添加到 lib/tasks 目录中(例如名为elasted_job.rake)并将代码放入其中。文件名并不重要,只要

  1. 它位于 lib/tasks 目录中
  2. 即可 扩展名为 .rake

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文