Selectively turning off Devise's flash notices in Rails 3

后端 未结 2 1506
挽巷
挽巷 2021-02-05 05:46

The Devise authentication framework uses flash notices everywhere. This makes it easy to integrate with apps but it leads to poor user experience sometimes.

I am wonde

2条回答
  •  后悔当初
    2021-02-05 06:14

    A better way to hide empty flash messages: if your message is in a div with class "notice" or "error" CSS3 lets you have a style like this:

    .notice:empty {
      display: none;
    }
    

    Which is nice because you can then always display the flash div and it'll only show up when there's something there. I use this to update flash messages in responses from ajax calls which otherwise wouldn't update flash messages because there's no page re-load involved. It gives a consistent look to messages that come as a result of ajax calls.

提交回复
热议问题