未初始化的常量Delayed :: Job [英] uninitialized constant Delayed::Job

查看:62
本文介绍了未初始化的常量Delayed :: Job的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将delay_job gem添加到我的gemfile中并正确安装,但是当我尝试运行以下行时:

I've added the delayed_job gem to my gemfile and installed correctly but when I try to run the following line:

Delayed::Job.enqueue do_it(), 0, 1.minutes.from_now.getutc

我明白了错误'未初始化的常量Delayed :: Job'

I get the error 'uninitialized constant Delayed::Job'

有人可以解释我在这里需要做什么吗?我曾尝试过先运行 rake jobs:work,但它还会返回未初始化的常数Delayed :: Job错误。此外,我在文件(application.rb)中添加了 require'delayed_job',但运气不佳。

Can somebody explain what i need to do here? I've tried running 'rake jobs:work' beforehand but it also returns the 'uninitialized constant Delayed::Job' error. Additionally, I've added "require 'delayed_job'" to the file (application.rb) without much luck.

推荐答案

Did您遵循自述文件上的安装说明吗? https://github.com/collectiveidea/delayed_job

Did you follow the installation instructions on the README file? https://github.com/collectiveidea/delayed_job

添加此到您的gemfile:

Add this to your gemfile:

gem 'delayed_job_active_record'

,然后在控制台上运行它:

and then run this at the console:

$ rails generate delayed_job:active_record
$ rake db:migrate

您需要在数据库中创建延迟作业表(此操作假定您正在使用活动记录。)

You need to create the delayed jobs table in the database (this assumes you're using active record).

对于Rails 3,您需要做的就是将其包含在gemfile中,在上面运行该代码以创建表并迁移数据库,然后重新启动服务器并运行!

For Rails 3, all you need to do is include it in the gemfile, run that code above to create the table and migrate the database, then restart your server and go!

这篇关于未初始化的常量Delayed :: Job的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆