【问题标题】:Customize devise confirmation email自定义设计确认电子邮件
【发布时间】:2012-09-03 07:02:42
【问题描述】:

欢迎 xxx@xxxxx.com!您可以通过以下方式确认您的帐户电子邮件 下面的链接:在此处输入代码确认我的帐户

我想把这条消息编辑成这样

我的项目名称 你好xxxxx 单击此处确认您的电子邮件

【问题讨论】:

    标签: ruby-on-rails devise-confirmable


    【解决方案1】:

    只需生成设计视图

    rails g 设计:视图

    然后您可以访问默认的邮件配置

    your_app/app/views/devise/mailer

    • confirmation_instructions.html.erb
    • reset_password_instructions.html.haml
    • unlock_instructions.html.haml

    【讨论】:

    • 这仍然适用于 rails 4.2 / Devise 3.5 请注意,如果您有多个设计模型,则会在每个设计模型视图目录中创建邮件目录:例如 your_app/app/views/user/maileryour_app/app/views/admin/mailer。 ..
    【解决方案2】:

    检查devise.en.yml 以查找设计翻译。您可以将project_name 传递给翻译;例如:

    t('welcome', :project_name => project.name)

    并且在 yml 文件中:

    welcome_message: 'My %{project_name} Hello xxxxx click here to confirm you email'

    【讨论】:

    • 你的意思是在邮件:confirmation_instructions:主题:'Cheeve.it 确认说明' reset_password_instructions:主题:'重置密码说明' unlock_instructions:主题:'解锁说明'
    【解决方案3】:

    当资源通常是 usersadmin

    时,我相信您想从 app\view\resource\mailer 自定义 confirmation_instructions.html.erb 文件

    首先,检查您是否在config/initializers/devise.rb 中设置了config.scoped_views = true 多亏了这一点,安装程序正在资源的视图文件夹中查找模板,而不是app\views\devise\mailer 中的默认模板

    使用loginusername等可以通过以下方式<%= @resource.login %>

    毕竟,请确保重新启动服务器。供参考,检查类似问题Ruby/Rails: How do you customize the mailer templates of Devise?

    【讨论】:

      猜你喜欢
      • 2011-08-22
      • 1970-01-01
      • 2014-09-19
      • 2012-03-10
      • 2019-08-04
      • 2013-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多