How to add a new flash message to devise.en.yml?

旧街凉风 提交于 2019-12-24 22:18:26

问题


I want to display a new flash msg on logout under a particular condition.. I'm overriding the after_sign_out_path_for method in application_controller.rb. I have added a new msg in devise.en.yml too. How do I flash the new msg on logout when its redirected to sign in page???

application_controller.rb:

 def after_sign_out_path_for(resource_or_scope)
    if is_already_logged_in?
     flash.keep[:notice] =  t("devise.failure.concurrent")// IS NOT WORKING
     new_user_session_path
    else
      new_user_session_path(resource)
    end
  end

devise.en.yml:

en:
  devise:
    confirmations:
      confirmed: "Your account was successfully confirmed. You are now signed in."
      send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes."
      send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes."
    failure:
      already_authenticated: "You are already signed in."
      inactive: "Your account was not activated yet."
      invalid: "Invalid email or password."
      invalid_token: "Invalid authentication token."
      locked: "Your account is locked."
      not_found_in_database: "Invalid email or password."
      timeout: "Your session expired, please sign in again to continue."
      unauthenticated: "You need to sign in or sign up before continuing."
      unconfirmed: "You have to confirm your account before continuing."
      // NEW MESSAGE ADDED
      concurrent: "You are signed out due to concurrent sessions!"
    mailer:
      confirmation_instructions:
        subject: "Confirmation instructions"

来源:https://stackoverflow.com/questions/20782770/how-to-add-a-new-flash-message-to-devise-en-yml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!