views:

54

answers:

2

This is for http://github.com/tobi/delayed_job

the example says:

script/generate delayed_job_migration

if I run it

$ script/generate delayed_job_migration
Couldn't find 'delayed_job_migration' generator

On github, there is a generators folder, an init.rb, a lib folder, and a tasks folder, where should they go into our project? (using Rails 3.0)

It also says add code like this:

class NewsletterJob < Struct.new(:text, :emails)
  def perform
    emails.each { |e| NewsletterMailer.deliver_text_to_email(text, e) }
  end    
end  

Delayed::Job.enqueue NewsletterJob.new('lorem ipsum...', Customers.find(:all).collect(&:email))

but where should this code go? to the controller or in a lib file? and how do you invoke it? I suppose the enqueue code need to only run once really?

+1  A: 

Try the collective idea delayed_job http://github.com/collectiveidea/delayed_job . I think it is more complete, I have used it and I had no problem.

1) Just install

2) run the migration

3) start the workers with the command

rake jobs:work

4) put inside the controller the command with the delay. For example @video.delay.convert

And you are ready.

Sometimes you might need to restart the workers to take effect the new changes you made.

JohnDel