Rails emails using the recipient's locale.
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
class NotificationMailer < ActionMailer::Base | |
default from: "Sender <sender@example.com>" | |
def mail_with_locale(headers = {}, &block) | |
locale = headers.delete(:locale) || I18n.default_locale | |
I18n.with_locale(locale) { mail_without_locale(headers, &block) } | |
end | |
alias_method_chain :mail, :locale | |
def notification(user) | |
mail to: user.email, locale: user.locale | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment