2
在我en.yml我有这样的:Rails 3是否缺少错误翻译?
en:
errors:
format: "%{message}"
messages:
blank: "%{attribute} can't be blank"
invalid: "%{attribute} is invalid"
too_short: "%{attribute} is too short"
too_long: "%{attribute} is too long"
wrong_length: "%{attribute} is the wrong length"
taken: "%{attribute}, {value}, is already taken"
这是我的用户模型至今:
validates_presence_of :username
validates_uniqueness_of :username
validates_length_of :username, :within => 4..15
validates_format_of :username, :with => /^\w+$/i
validates_presence_of :password
validates_length_of :password, :within => 6..20
当我测试的随机数据,所有的错误信息工作的伟大,除了validates_uniqueness_of,它返回默认'已经被采纳'
非常感谢您提前。
非常感谢! – David 2011-03-07 22:01:00
不客气,如果这解决了你的问题,你应该考虑选择接受的答案,这里左边的零。玩的开心! - 顺便说一下,什么解决方案帮助你? '%'符号? – ecoologic 2011-03-07 23:35:10
是的,就是这样 - 抱歉,我今天没有意识到这个复选框,我会开始使用它。 – David 2011-03-27 00:18:51