[英]How to change Validation error messages in devise in Rails 5
I have changed the default minimum length for password from @@password_length = 5..128 to 6..128. 我将密码的默认最小长度从@@ password_length = 5..128更改为6..128。 When I give failing validation for password during the signup, the validation error is showing as "is too short (minimum is 5 characters)". 当我在注册过程中未通过密码验证时,验证错误显示为“太短(最少5个字符)”。 How to change this error message to "minimum 6 characters". 如何将此错误消息更改为“最少6个字符”。 I read some anuswers in stackoverflow they say to look in to devise.views.en.yml . 我阅读了stackoverflow中的一些回答,他们说他们去看devise.views.en.yml 。 But still can't change the error message. 但是仍然无法更改错误消息。
My devise.views.en.yml (password field) looks like: 我的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.
Suggestions are most welcomed 建议是最欢迎的
You'll have to override the devise.en.yml file in the following manner 您必须按以下方式覆盖devise.en.yml文件
en:
activerecord:
errors:
models:
user:
attributes:
password:
too_short: "Password is too short (minimum is %{count} characters)"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.