Ruby on rails 4 如何在action mailer中使用i18n
假设我在用户模型中记录用户的偏好Ruby on rails 4 如何在action mailer中使用i18n,ruby-on-rails-4,rails-i18n,Ruby On Rails 4,Rails I18n,假设我在用户模型中记录用户的偏好 User.lang=:en,:jp,… 如果我可以在邮件中获得用户信息,我如何发送带有18n的电子邮件 我在rake任务中调用以下mailer class NotificationMailer < ApplicationMailer def notify_user(user, queues) @user, @queues = user, queues mail(to: [@user.email], from: "sa
User.lang=:en,:jp,…
如果我可以在邮件中获得用户信息,我如何发送带有18n的电子邮件
我在rake任务中调用以下mailer
class NotificationMailer < ApplicationMailer
def notify_user(user, queues)
@user, @queues = user, queues
mail(to: [@user.email],
from: "samplegmail.com",
subject: "~~~",
content_type: "text/html"
)
end
class NotificationMailer
您可以使用I18n.with\u locale
临时设置区域设置,因此只需在传递给with\u locale
的块中创建邮件即可
I18n.with_locale(@user.lang) do
mail(to: [@user.email],
from: "samplegmail.com",
subject: "~~~",
content_type: "text/html"
)
end
你是如何生成邮件的?@Goot我在rake任务中发送邮件吗