Created
July 1, 2015 00:27
-
-
Save Sija/ace2efa3aedba9292528 to your computer and use it in GitHub Desktop.
Make Rails' 4.2 ActionMailer locale aware or i18n for ya emailz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActionMailer | |
class MessageDelivery | |
private | |
def enqueue_delivery(delivery_method, options={}) | |
args = @mailer.name, @mail_method.to_s, delivery_method.to_s, I18n.locale.to_s, *@args | |
ActionMailer::DeliveryJob.set(options).perform_later(*args) | |
end | |
end | |
class DeliveryJob | |
def perform(mailer, mail_method, delivery_method, locale, *args) # :nodoc: | |
I18n.with_locale(locale) do | |
mailer.constantize.public_send(mail_method, *args).send(delivery_method) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This should ideally land in upstream or even in
ActiveJob
. And since it's possible to support it transparently to the user... @rails team, could we plz? :)