Rails Disable devise flash messages

Marat_Galiev picture Marat_Galiev · Apr 23, 2011 · Viewed 16.4k times · Source

How I can disable all Devise gem flash messages ("successfully signed in","you logged out")? Thanks.

Answer

Michelle Tilley picture Michelle Tilley · Apr 23, 2011

Probably the easiest way to do this is to

  1. Define each message as a blank string
  2. Check the length of the string before you show a flash message.

In your devise.en.yml file, specify each message as empty:

en:
  errors:
    messages:
      not_found: ''
      already_confirmed: ''
      not_locked: ''

etc. Next, in your layout, check for blank flash strings before you output them.

<% flash.each do |key, value| %>
  <%= content_tag :div, value, :class => "flash #{key}" unless value.blank? %>
<% end %>