设计 - 闪光通知 [英] Devise - Flash Notices
本文介绍了设计 - 闪光通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 Devise 中使用 rails,无论何时您登录或注销,devise 都会在页面上吐出 Flash 通知,从 UI 的角度来看这似乎没有必要,这通常很明显,对吧?
Using rails with Devise, anytime you sign in or signout devise spits a Flash Notice on the page which doesn't seem necessary from a UI perspective, it's usually pretty obvious, right?
有没有办法在 Devise for Sign In 和 Sign Outs 中关闭 Flash 通知?
Is there a way to turn off flash notices in Devise for Sign In and Sign Outs?
谢谢
推荐答案
只需尝试在 session_controller.rb 中添加此代码即可.
Just try adding this code in your sessions_controller.rb.
class SessionsController < Devise::SessionsController
after_action :clear_sign_signout_flash, :only => [:create, :destroy]
protected
def clear_sign_signout_flash
if flash.key?(:notice)
flash.delete(:notice)
end
end
end
希望这有帮助:-)
这篇关于设计 - 闪光通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文