Reputation: 151076
For http://github.com/collectiveidea/delayed_job
Let's say I just start a brand new Rails project and want the following to be run every 1 minute:
puts "Time is now #{Time.now}"
How would I add it to the project?
The README says:
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 you put this content? Do you run it once to enqueue? How do you set the start time and the frequency?
Upvotes: 1
Views: 189
Reputation: 7732
delayed_job is gem for background tasks. You need a scheduling tool for that. I recommend http://github.com/javan/whenever.
http://www.ruby-toolbox.com/categories/scheduling.html
Upvotes: 1