对于那些熟悉 Devise 及其功能的人,您应该对 config/locales 目录中的 Devise.en.yml 文件有一些工作知识。该文件本质上在登录时会创建错误消息,即:如果您输入的密码错误,您应该会看到类似“invalid: 'Invalid email or password.”这样的错误消息。
在我的情况下,它不起作用,如果我输入错误的用户名/密码,什么也不会发生,它只是不会让您登录,但没有闪烁消息。
我的 devise.en.yml 文件内容都是绿色的,我不确定这是否应该是这样的,但我有一种预感,代码可能有问题?但这可能是也可能不是真正的原因。
不确定要包含哪些控制器或内容,因此一旦您提出要求,我将使用它们更新 OP。
这是我的应用程序的 devise.en.yml 文件:
en:
errors:
messages:
not_found: "not found"
already_confirmed: "was already confirmed"
not_locked: "was not locked"
devise:
failure:
unauthenticated: 'You need to sign in or sign up before continuing.'
unconfirmed: 'You have to confirm your account before continuing.'
locked: 'Your account is locked.'
invalid: 'Invalid email or password.'
invalid_token: 'Invalid authentication token.'
timeout: 'Your session expired, please sign in again to continue.'
inactive: 'Your account was not activated yet.'
sessions:
signed_in: 'Signed in successfully.'
signed_out: 'Signed out successfully.'
passwords:
send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
updated: 'Your password was changed successfully. You are now signed in.'
confirmations:
send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
confirmed: 'Your account was successfully confirmed. You are now signed in.'
registrations:
signed_up: 'You have signed up successfully.'
updated: 'You updated your account successfully.'
destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
unlocks:
send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
unlocked: 'Your account was successfully unlocked. You are now signed in.'
mailer:
confirmation_instructions: 'Confirmation instructions'
reset_password_instructions: 'Reset password instructions'
unlock_instructions: 'Unlock Instructions'