我想将附件添加到通过设计(徽标图像)重置密码时发送的电子邮件,并且我想使用用户的语言环境来本地化电子邮件文本。任何人都可以帮助并告诉我要覆盖什么来做到这一点吗?
问问题
3559 次
3 回答
7
您需要将徽标图像添加为附件。
为此,请按照链接中的说明覆盖默认的 Devise::Mailer: https ://github.com/plataformatec/devise/wiki/How-To:-Use-custom-mailer
然后,使用添加附件attachments.inline['logo.png']=
:
def reset_password_instructions(record, opts={})
attachments.inline['logo.png'] = File.read('app/assets/images/logo.png')
super(record, opts)
end
在视图中您可以使用attachments['logo.png'].url
:
<%= image_tag(attachments['logo.png'].url, alt: 'Logo') %>
于 2013-06-11T05:10:21.267 回答
2
只需运行rails generate devise:views
和编辑模板app/views/devise/mailer/reset_password_instructions.html.erb
于 2012-04-13T20:49:16.493 回答
2
我正在为 rails 5 应用程序使用设计 4.3。需要附加参数。
def reset_password_instructions(record, token, opts={})
attachments.inline['logo.png'] = File.read("#{Rails.root}/app/assets/images/logo.png")
super(record, token, opts)
end
于 2018-02-23T11:00:03.087 回答