Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uninitialized constant Delayed::Job

Tags:

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

I get the error 'uninitialized constant 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.

like image 806
Gerard Avatar asked Jul 10 '11 14:07

Gerard


2 Answers

If you've upgraded to delayed_job version >=3 you'll need to add this (presuming you're using ActiveRecord):

# Gemfile
gem 'delayed_job_active_record'
like image 103
Zubin Avatar answered Sep 18 '22 04:09

Zubin


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

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).

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!

like image 34
iwasrobbed Avatar answered Sep 21 '22 04:09

iwasrobbed