更改设计消息“已发送电子邮件”

我在我的ruby on rails应用程序中使用了devise gem。 在用户注册时,如果已存在电子邮件,则会显示默认消息“已收到电子邮件”。

我在en.yml中更改了此消息

activerecord: errors: messages: taken: "User with same email already exists. Please try with another email address." 

在视图中我使用过:

 

现在我得到的信息是

 "Email User with same email already exists. Please try with another email address." 

问题是在开始时附加了“电子邮件”。

有没有其他方法可以更改此默认消息?

将邮件格式更改为

 en: errors: format: "%{message}" 

默认为"%{attribute} %{message}"

UPDATE

还有另一种解决方案。 我知道这是一个解决方法,但这里是..删除现有的validation,并添加自定义validation。

 validate :email_uniqueness def email_uniqueness self.errors.add(:base, 'User with same email already exists. Please try with another email address.') if User.where(:email => self.email).exists? end 

注意:在进行更新时,您应该考虑现有用户