如何向devise.en.yml添加新的flash消息?

时间:2013-12-26 09:58:38

标签: ruby-on-rails-3 devise

我想在特定条件下注销时显示新的flash msg。我正在覆盖after_sign_out_path_for中的application_controller.rb方法。我在devise.en.yml中添加了一个新的消息。当重定向到登录页面???

时,如何在注销时刷新新消息

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"

0 个答案:

没有答案