Rails & Devise: Turn off flash messages

Do you find all the flash messages Devise generates a bit excessive?

At the very least, I needed to turn off the sign-in and sign-out success messages. Turns out this is really simple.

In the Devise locale file (e.g., devise.en.yml), just empty out the message strings.

Don’t delete the lines altogether or you’ll get translation not found errors. I suggest leaving the original lines as a reference.

Why this works:

The helper method set_flash_message used by the Devise controllers ignores empty messages.

In gems/devise-3.2.3/app/controllers/devise_controller.rb:

This method is used, for example, in the devise/sessions_controller.rb: