Devise/Rails - How to remove a particular flash message? (Signed in Successfully)

前端 未结 8 894
囚心锁ツ
囚心锁ツ 2020-12-13 12:38

Using Devise, I would like to know if there is a way to remove a particular flash message? (Signed in Successfully).

I care about other msg in the view, so It is jus

8条回答
  •  独厮守ぢ
    2020-12-13 13:17

    Another flexible way to to this is to unset the notice after the action:

    class SessionsController < Devise::SessionsController
      after_action :remove_notice, only: :destroy
    
      private
    
      def remove_notice
        flash[:notice] = nil
      end
    end
    

    With this solution you can add conditions to removing or not the notice.

提交回复
热议问题