README.rdoc in resque_mailer-0.2.1 vs README.rdoc in resque_mailer-1.0.0
- old
+ new
@@ -1,47 +1,65 @@
= ResqueMailer
-A gem plugin which allows messages prepared by ActionMailer to be delivered asynchronously.
-Assumes that you're using Resque (http://github.com/defunkt/resque) for your background jobs.
+A gem plugin which allows messages prepared by ActionMailer to be delivered
+asynchronously. Assumes you're using Resque (http://github.com/defunkt/resque)
+for your background jobs.
+Works in both Rails 2.x and Rails 3.x.
+
== Usage
Include Resque::Mailer in your ActionMailer subclass(es) like this:
class MyMailer < ActionMailer::Base
include Resque::Mailer
end
-Or if you want to always use asynchronous delivery by default, create an initializer in your
-Rails project or piggyback on your load_resque.rb initializer:
+Now, when <tt>MyMailer.deliver_subject_email</tt> is called, an entry will be
+created in the job queue. Your Resque workers will be able to deliver this
+message for you. The queue we're using is imaginatively named +mailer+, so
+just make sure your workers know about it and are loading your environment:
- class ActionMailer::Base
- include Resque::Mailer
- end
+ QUEUE=mailer rake environment resque:work
-Now, when MyMailer.deliver_subject_email is called, an entry will be created in the job queue.
-Your Resque workers will be able to deliver this for you; the queue we're using is imaginatively
-named +mailer+. Just make sure your workers know about it and are loading your environment:
+Note that you can still have mail delivered synchronously by using the bang
+method variant:
- QUEUE=mailer rake environment resque:work
+ MyMailer.deliver_subject_email!
-Note that you can still have mail delivered synchronously by using the bang method variant:
-MyMailer.deliver_subject_email!
+Oh, by the way. Don't forget that your async mailer jobs will be processed by
+a separate worker. This means that you should resist the temptation to pass
+database-backed objects as parameters in your mailer and instead pass record
+identifiers. Then, in your delivery method, you can look up the record from
+the id and use it as needed.
+== Rails 3 Support
+
+Rails 3 has made some changes to the ActionMailer interface. Instead of
+calling <tt>MyMailer.deliver_subject_email(params)</tt>, you'll want to call
+<tt>MyMailer.subject_email(params).deliver</tt>.
+
+You still need to include <tt>Resque::Mailer</tt> in your mailer as described
+above. Everything else should work as expected.
+
== Installation
-Install it as a plugin or as a gem plugin.
+Install it as a plugin or as a gem plugin from Gemcutter:
+ gem install resque_mailer
script/plugin install git://github.com/zapnap/resque_mailer.git
- # config/environment.rb
+ # Rails 2: edit config/environment.rb
config.gem 'resque_mailer'
+ # Rails 3: add it to your Gemfile
+ gem 'resque_mailer'
+
== Testing
-You don't want to be sending actual emails in the test environment, so you can configure the
-environments that should be excluded like so:
+You don't want to be sending actual emails in the test environment, so you can
+configure the environments that should be excluded like so:
# config/initializers/resque_mailer.rb
Resque::Mailer.excluded_environments = [:test, :cucumber]
== Note on Patches / Pull Requests
@@ -53,7 +71,8 @@
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
* Send me a pull request. Bonus points for topic branches.
== Credits
-This work is essentially a forked version of delayed_job_mailer (http://github.com/andersondias/delayed_job_mailer) by Anderson Dias
-(which in turn was inspired by Alexander Lang's workling_mailer). Enhanced and modified to work with Resque by Nick Plante.
+This work is essentially a forked version of delayed_job_mailer
+(http://github.com/andersondias/delayed_job_mailer) by Anderson Dias. Enhanced
+and modified to work with Resque by Nick Plante.