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

前端 未结 8 899
囚心锁ツ
囚心锁ツ 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条回答
  •  Happy的楠姐
    2020-12-13 13:24

    From my point of view I dont see the point in emptying a string translation, when you can easily modify how the controller is working. I guess this way is much more correct and satisfying.

    A better answer could be to override destroy method in sessionController.

    Just creates a file placed in: app/controllers/sessions_controller.rb

    As you can see we comment the line creating the flash message.

    class SessionsController < Devise::SessionsController 
      # DELETE /resource/sign_out
      def destroy
        signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))
        #set_flash_message :notice, :signed_out if signed_out && is_flashing_format?
        yield if block_given?
        respond_to_on_destroy
      end
    end
    

提交回复
热议问题