Rails Disable devise flash messages
Solution 1:
Probably the easiest way to do this is to
- Define each message as a blank string
- 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 %>
Solution 2:
An answer better suited for me was to override the Devise Session Controller like this
class 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 safely overrides the create and destroy method removing the flash message