簡體   English   中英

如何在Rails 5中的devise中更改Validation錯誤消息

[英]How to change Validation error messages in devise in Rails 5

我將密碼的默認最小長度從@@ password_length = 5..128更改為6..128。 當我在注冊過程中未通過密碼驗證時,驗證錯誤顯示為“太短(最少5個字符)”。 如何將此錯誤消息更改為“最少​​6個字符”。 我閱讀了stackoverflow中的一些回答,他們說他們去看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)"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM