ruby-on-rails - 在 current_password 字段中设计更改验证消息

这是我的代码..

<label>Old Password</label>
 <%= f.password_field :current_password, :class=>"myaccount_textbox" %>
<label class="error" for="current_password">
 <%= validation_errors resource.errors['current_password'] %>
</label>
...........

表单提交时,密码错误,默认验证消息 - 无效

要求 - 需要更改默认消息

devise (3.2.4)rails 3.2.13 我从 link 尝试过的内容

在 en.yml 中

en:
  activerecord:
    errors:
      models:
        user:
          attributes:
            current_password:
              confirmation: "Password is incorrect"

目前它不起作用,我只收到默认消息,要进行哪些更改才能修复此问题?

最佳答案

尝试:

en:
  activerecord:
    attributes:
      user:
        current_password: "Password"
    errors:
      models:
        user:
          attributes:
            current_password:
              invalid: "is incorrect!"

  devise:  
    failure:  
      invalid: 'Password is incorrect!'

引用这个link选择正确的选项以显示 Devise 的密码错误消息。

https://stackoverflow.com/questions/23264927/

相关文章:

types - InnoSetup : custom setup type - display me

clojure - 是否可以检索定义变量的条件图?

scala - 修复更高种类类型的类型推断

angularjs - 关于Angular $q defer对象的问题

dart - 如何在 Dart 中产生一个新的隔离?

maven - java.lang.IllegalStateException : Could no

asp.net - 在 RDLC 报告 asp.net 中放置超链接

azure - WAStorageEmulator.exe 启动失败

datomic - 将任意键/值条目与数据实体一起存储

shell - 将所有第二层 mp3 递归转换为第三层并更新 ID3