加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Rails / Devise – 使用link_to自定义Flash消

发布时间:2020-12-16 20:32:21 所属栏目:百科 来源:网络整理
导读:我想定制devise提供的以下闪存msg 在devise.en.yml文件中: devise: failure: unconfirmed: 'You have to confirm your account before continuing.' 与ruby代码,以获得一个链接到new_user_confirmation_path. 换句话说,我想要我的Flash消息显示如下: 'You
我想定制devise提供的以下闪存msg
在devise.en.yml文件中:
devise:
   failure:
      unconfirmed: 'You have to confirm your account before continuing.'

与ruby代码,以获得一个链接到new_user_confirmation_path.

换句话说,我想要我的Flash消息显示如下:

'You have to confirm your account before continuing. Didn't receive confirmation instructions?'

哪里没有收到确认说明?是指向new_user_confirmation_path的链接.

我想知道如果我可以这样做,而不需要编辑用户控制器,因为Devise默认情况下不提供它.

感谢您的回答!

解决方法

new_user_confirmation_path是与/ users / confirmation / new相当的静态网址

所以你可以在devise.en.yml文件中做到这一点:

devise:
  failure:
    unconfirmed: "You have to confirm your account before continuing. <a href='/users/confirmation/new'>Didn't receive confirmation instructions?</a>"

在控制器中显示闪存的操作中,请确保使用.html_safe.闪光[:错误] .html_safe

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读