On Monday, May 16, 2011 11:36:30 PM UTC-6, News Aanad
wrote:>
>
> 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
>
> end
>
> end
>
> end
>
> Delayed::Job.enqueue( MyClass.new )
> #m.perform
>
>
> 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
>
>
The Delayed::Job constant is defined dynamically when the delayed job
backend is setup by Delayed::Worker.guess_backend (it selects ActiveRecord
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 when
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
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.