Where can I change the “Email has already been taken” error message?

流过昼夜 提交于 2019-12-23 17:18:57

问题


I need customize the message error: Email has already been taken for email, I'm working with Ruby 1.9.2, Rails 3.1.3, Devise 1.5.3, I tried change the message in: config/locales/devise.en.yml and in my config/locales/en.yml but it doesn't works!

In my models/user I have:

validates_uniqueness_of :email, :message => "este mail ya sido utilizado"

It shows that message but it also shows: Email has already been taken.


回答1:


I never used Devise, but I think the "taken" message is an ActiveRecord error message (not specific to the Devise gem). If you plan on using a non-english locale I would advice you to change the default locale instead of adding non-english content to the EN one.

sp:
  activerecord:
    errors:
      messages:
        taken: "este %{model} ya sido utilizado"


来源:https://stackoverflow.com/questions/9006270/where-can-i-change-the-email-has-already-been-taken-error-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!