Uninitialized constant Delayed::Job (NameError)

hi I am implementing delayed_job in my rails app.

my code is:
file name is: my_worker.rb

require “delayed_job”
require “rubygems”

class MyClass

def perform

while true do

  puts "I am in My class!!!"
  sleep 2




Delayed::Job.enqueue( MyClass.new )

when i am executing this(ruby my_worker.rb ) file it gives me error like
“uninitialized constant Delayed::Job (NameError)”
what should i do?
My platform is :windows 7
Rails version: 3.0.6
Ruby : 1.9.2

On Monday, May 16, 2011 11:36:30 PM UTC-6, News A. wrote:

class MyClass
My platform is :windows 7
Rails version: 3.0.6
Ruby : 1.9.2

The Delayed::Job constant is defined dynamically when the delayed job
backend is setup by Delayed::Worker.guess_backend (it selects
as your backend if ActiveRecord is defined) or by
Delayed::Worker.backend =
[back end].

The rspec tests use the latter method to setup the back end while the
initialization defined by the Delayed::Railtie does the former for you
rails is initialized.

So, you need to run your code in the context of rails or manually do the
setup yourself. Try:

rails runner path/to/my_worker.rb

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs