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

ruby-on-rails – 禁用响应者gem flash消息进行设计登录

发布时间:2020-12-17 01:33:02 所属栏目:百科 来源:网络整理
导读:我们在项目中运行设计和响应者宝石.我们已经删除了signed_in和signed_up flash消息,如下所述: Rails Disable devise flash messages config / locales / devise.en.yml的相关部分: devise: sessions: signed_in: '' signed_out: '' 但是现在我们收到的消息
我们在项目中运行设计和响应者宝石.我们已经删除了signed_in和signed_up flash消息,如下所述: Rails Disable devise flash messages

config / locales / devise.en.yml的相关部分:

devise:
  sessions:
    signed_in: ''
    signed_out: ''

但是现在我们收到的消息是“用户已成功创建”.我们已将此追溯到响应者宝石.这是我们的config / locales / responders.en.yml文件:

en:
  flash:
    actions:
      create:
        notice: '%{resource_name} was successfully created.'
      update:
        notice: '%{resource_name} was successfully updated.'
      destroy:
        notice: '%{resource_name} was successfully destroyed.'
        alert: '%{resource_name} could not be destroyed.'

我明白为什么会说用户是创建的(设计会话是用用户的资源创建的),但到目前为止我尝试的所有内容都没有删除该消息(除了删除整个响应者宝石).

我已经尝试将一些带有空消息的特定条目添加到responders.en.yml文件中:

en:
  flash:
    actions:
      create:
        notice: '%{resource_name} was successfully created.'
      update:
        notice: '%{resource_name} was successfully updated.'
      destroy:
        notice: '%{resource_name} was successfully destroyed.'
        alert: '%{resource_name} could not be destroyed.'
    users:
      create:
        notice: ''
        success: ''
    sessions:
      create:
        notice: ''
        success: ''

但我们仍然得到相同的“用户已成功创建.”登录后闪烁消息.

Rails:4.0.4
设计:3.2.2
响应者:1.0.0

如何在用户登录并创建会话时禁用此Flash消息?

解决方法

我自己也遇到了这个问题,我想我应该回答一下这个问题.你真的很接近你的尝试,但嵌套有点错误.

en:
  flash:
    actions:
      create:
        notice: '%{resource_name} was successfully created.'
        alert: '%{resource_name} could not be created.'

      ...your other responders here...

    devise:
      sessions:
        create:
          notice: ''

与您的问题唯一真正的区别是会话嵌套在设计之下.

祝好运!

(编辑:李大同)

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

    推荐文章
      热点阅读