10

As the name says, I am using devise for user auth in a rails 3 app Upon user log out, there is a flash notice, "User Successfully signed out" that I don't want to appear. However, I can't figure out how to remove the notice.

Is there a way to get around just making it blank? I would like to completely remove the notice so that, ideally, there's not even an html div for notice

Charles
  • 50,943
  • 13
  • 104
  • 142
Vasseurth
  • 6,354
  • 12
  • 53
  • 81

2 Answers2

35

If you explicitly put in a blank string for this in your locale file, then Devise "won't bother" to render the message at all (e.g. there won't even be an empty HTML div).

#en.yml
devise:
    sessions:
        signed_in: 'Signed in successfully.'
        signed_out: ''
cailinanne
  • 8,332
  • 5
  • 41
  • 49
  • 8
    I know this is a bit old, but for those of you who are wondering, the locale file is typically located at `config/locales/devise.en.yml` – richsinn Aug 06 '14 at 18:31
  • Here's a link to the locales file in the Devise repo for convenience https://github.com/heartcombo/devise/blob/master/config/locales/en.yml. You'll also want to override the `already_signed_out` message, in addition to `signed_out`. – Dylan Fisher Oct 04 '21 at 23:18
3

My routes.rb

devise_for :users, :controllers => {
  sessions: 'user/sessions'
}

My controller "account/sessions_controller.rb"

class User::SessionsController < Devise::SessionsController

  def destroy
    super
    flash.delete(:notice)
  end

end
Willem
  • 1,304
  • 1
  • 8
  • 7