如何在 Rails 5 中更改设计中的验证错误消息
How to change Validation error messages in devise in Rails 5
我已将密码的默认最小长度从@@password_length = 5..128 更改为6..128。当我在注册过程中给出密码验证失败时,验证错误显示为 "is too short (minimum is 5 characters)"。如何将此错误消息更改为 "minimum 6 characters"。我在 Whosebug 中读了一些答案,他们说要查看 devise.views.en.yml 。但是还是改不了错误信息
我的devise.views.en.yml(密码字段)看起来像:
passwords:
edit:
change_my_password: Change my password
change_your_password: Change your password
confirm_new_password: Confirm new password
new_password: New password
new:
forgot_your_password: Forgot your password?
send_me_reset_password_instructions: Send me reset password instructions
no_token: You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided.
send_instructions: You will receive an email with instructions on how to reset your password in a few minutes.
send_paranoid_instructions: If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes.
updated: Your password has been changed successfully. You are now signed in.
updated_not_active: Your password has been changed successfully.
欢迎提出建议
您必须按以下方式覆盖 devise.en.yml 文件
en:
activerecord:
errors:
models:
user:
attributes:
password:
too_short: "Password is too short (minimum is %{count} characters)"
我已将密码的默认最小长度从@@password_length = 5..128 更改为6..128。当我在注册过程中给出密码验证失败时,验证错误显示为 "is too short (minimum is 5 characters)"。如何将此错误消息更改为 "minimum 6 characters"。我在 Whosebug 中读了一些答案,他们说要查看 devise.views.en.yml 。但是还是改不了错误信息
我的devise.views.en.yml(密码字段)看起来像:
passwords:
edit:
change_my_password: Change my password
change_your_password: Change your password
confirm_new_password: Confirm new password
new_password: New password
new:
forgot_your_password: Forgot your password?
send_me_reset_password_instructions: Send me reset password instructions
no_token: You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided.
send_instructions: You will receive an email with instructions on how to reset your password in a few minutes.
send_paranoid_instructions: If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes.
updated: Your password has been changed successfully. You are now signed in.
updated_not_active: Your password has been changed successfully.
欢迎提出建议
您必须按以下方式覆盖 devise.en.yml 文件
en:
activerecord:
errors:
models:
user:
attributes:
password:
too_short: "Password is too short (minimum is %{count} characters)"