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

前端 未结 8 923
囚心锁ツ
囚心锁ツ 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:12

    Another way is if you override the Devise controller, in the create action, put this code, which deletes the flash message:

    class MyDevise::SessionsController < Devise::SessionsController
    
      # POST /resource/sign_in
      def create
        super
        flash.delete(:notice)
      end
    
      # DELETE /resource/sign_out
      def destroy
        super
        flash.delete(:notice)
      end
    
    end
    

    this was answered in this other SO question. For a blog post on how to override the Devise controller, see my blog post

提交回复
热议问题