The common pattern for interfacing with ActiveJob
in Rails is to set up a Job with a perform()
method that gets called asynchronously via perform_now
or perform_later
In the special case of Mailers, you can directly call deliver_now
or deliver_later
since ActiveJob
is well integrated with ActionMailer
.
The rails documentation has the following comments -
# If you want to send the email now use #deliver_now
UserMailer.welcome(@user).deliver_now
# If you want to send the email through Active Job use #deliver_later
UserMailer.welcome(@user).deliver_later
The wording makes it seem like deliver_now
will not use ActiveJob
to send the mail. Is that correct, and if so what's the true difference between deliver_now
and deliver_later
? Is one not asynchronous?
Similarly, does the same difference apply to perform_now
and perform_later
?
Thanks!