README.markdown in simple_worker-0.3.11 vs README.markdown in simple_worker-0.3.13

- old
+ new

@@ -32,20 +32,31 @@ def send_email # Put sending code here end end +Test It Locally +--------------- + +Let's say someone does something in your app and you want to send an email about it. + + worker = EmailWorker.new + worker.to = current_user.email + worker.subject = "Here is your mail!" + worker.body = "This is the body" + **worker.run** + Queue up your Worker -------------------- Let's say someone does something in your app and you want to send an email about it. worker = EmailWorker.new worker.to = current_user.email worker.subject = "Here is your mail!" worker.body = "This is the body" - worker.queue + **worker.queue** Schedule your Worker -------------------- There are two scenarios here, one is the scenario where you want something to happen due to a user @@ -53,12 +64,17 @@ worker = EmailWorker.new worker.to = current_user.email worker.subject = "Here is your mail!" worker.body = "This is the body" - worker.schedule(:start_at=>1.hours.since) + **worker.schedule(:start_at=>1.hours.since)** + + +Schedule your Worker Recurring +------------------------------ + The alternative is when you want to user it like Cron. In this case you'll probably want to write a script that will schedule, you don't want to schedule it everytime your app starts or anything so best to keep it external. Create a file called 'schedule_email_worker.rb' and add this: @@ -69,6 +85,21 @@ worker.to = current_user.email worker.subject = "Here is your mail!" worker.body = "This is the body" worker.schedule(:start_at=>1.hours.since, :run_every=>3600) -Now your worker will be scheduled to run every hour. +Now run it and your worker will be scheduled to run every hour. + +SimpleWorker on Rails +--------------------- + +SimpleWorker only supports Rails 3+. + +Setup: + +- Make a workers directory at RAILS_ROOT/app/workers. +- In application.rb, uncomment config.autoload_paths and put: + + config.autoload_paths += %W(#{config.paths.app}/workers) + +Now you can use your workers like their part of your app! +