16
A
回答
14
您可以使用validates_format_of_email_field_options
覆盖电子邮件验证的设置。但是,如果您只想更改消息,则可以将选项与merge_validates_format_of_email_field_options
合并,以便只覆盖您指定的选项。您在用户控制器中指定如下设置:
class User < ActiveRecord::Base
acts_as_authentic do |c|
c.merge_validates_format_of_email_field_options :message => 'My message'
end
end
您还可以更改长度和唯一性验证的设置。还有更多其他设置,请查看documentation,在每个模块的:: Config部分中,您可以找到设置及其默认值以及如何覆盖它们。
或者,您可以使用本地化并设置error_messages.email_invalid
(这是插件在将其设置为默认英语句子之前查找的内容,在建立国际应用程序时也很有用)。
16
authlogic为此具有特殊设置:
class UserSession < Authlogic::Session::Base
generalize_credentials_error_messages true
end
的错误信息将是相同的:“电子邮件/密码组合是无效的”,密码或电子邮件是否是坏的。在en.yml文件
它为我改变
generalize_credentials_error_messages "Try again"
4
覆盖Authlogic错误信息:您可以更改消息文本中指定的字符串,而不是true
。
en:
authlogic:
error_messages:
login_blank: "Please enter the email address."
login_not_found: "This email address is already in the system. Please choose a different email address."
login_invalid: "Please enter a valid email address."
相关问题
- 1. 自定义authlogic错误消息
- 2. 使用simple_form自定义错误消息
- 3. 自定义错误消息
- 4. 用自定义消息替换错误
- 5. R,闪亮,自定义错误消息
- 6. 自定义Spring错误消息
- 7. 翻译自定义错误消息
- 8. asp.NET - 自定义错误消息
- 9. Gmap Primefaces Geocode自定义错误消息
- 10. 自定义消息错误jQuery验证
- 11. JSF自定义消息验证错误
- 12. 运行时自定义消息 - 错误
- 13. FileHelper库 - 自定义错误消息
- 14. Ansible Display自定义错误消息“stat”
- 15. WSO2 Api Manager自定义错误消息
- 16. WF ThrowActivities和自定义错误消息?
- 17. 自定义repl/nrepl错误消息
- 18. kohana自定义验证错误消息
- 19. 自定义关联错误消息
- 20. 设计自定义错误消息
- 21. 自定义错误消息和Laravel 5.1
- 22. FOSUserBundle自定义错误消息change_password
- 23. Linux Bash Shell自定义错误消息
- 24. jqgrid中的自定义错误消息
- 25. 自定义错误消息8
- 26. 自定义NSFormatter和错误消息
- 27. JWPLAYER自定义错误消息
- 28. Rails 4.2 ActionController:BadRequest自定义错误消息
- 29. 自定义所需的错误消息
- 30. 自定义消息的IIS错误
谢谢你添加这个。没有很多地方提到如何处理登录时的凭证错误。 – jpcamara 2011-08-24 02:15:39