Unitialize variable delayed_job

My code: path: app_root\lib\my_worker.rb module MyModule require “delayed_job” class MyWorker < Delayed::Worker def perform while true do puts “I am my worker!!!” sleep 2 end end def create_job Delayed::Job.enqueue(MyWorker.new) # MyWorker.enqueue end end end Path: app_root\my_script.rb

require “./lib/my_worker” require “delayed_job” require “rubygems”

class MyScript #MyModule::MyWorker.enqueue(1) m = MyModule::MyWorker.new #m.create_job end

when i am trying to run my_script.rb file from cmd it gives me error like

C:\my_delayed_job>ruby my_script.rb internal:lib/rubygems/custom_require:29:in `require’: no such file to load –

C:/my_delayed_job/my_script.rb/delayed_job (LoadError) from internal:lib/rubygems/custom_require:29:in require' from my_script.rb:4:in

Can any body resolve this problem?

Did you include the delayed_job gem requirement in your Gemfile (assuming that you are on Rails 3)?

One more remark: when you include the gem in your Gemfile, you have two options:

  1. Load gem at start

gem “delayed_job”

This will already require the gem and it will be available for your whole application

  1. Require in specific places

gem “delayed_job”, :require => nil

This will prevent the gem from being required at the start of your application and you’ll need to require it yourself where applicable.

Unless you have a very good reason for not doing so, you should go for option 1.

If this is not your problem, I’m suspecting Windows might be it and the gem isn’t compatible with Windows (another reason to do Rails development in a Linux VM).

Best regards

Peter De Berdt