设计重置密码的邮件模板

lin*_*_er 5 devise ruby-on-rails-3

我想添加通过设计(徽标图像)重置密码时发送的电子邮件的附件,我还想使用用户的区域设置来本地化电子邮件文本.任何人都可以帮助并告诉我要覆盖什么来做到这一点?

hae*_*g87 6

您需要将徽标图像添加为附件.

为此,请按照链接中的说明覆盖默认的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
Run Code Online (Sandbox Code Playgroud)

在视图中,您可以使用attachments['logo.png'].url:

<%= image_tag(attachments['logo.png'].url, alt: 'Logo') %>
Run Code Online (Sandbox Code Playgroud)