0
在敏捷Web开发书,建议使一个单元测试如下:翻译长度验证错误消息
assert_equal I18n.translate('activerecord.errors.messages.taken'),
product.errors[:title].join('; ')
我尝试使用此其它错误消息,如长度验证TOO_SHORT消息,但得到的错误:
assert_equal I18n.translate('activerecord.errors.messages.too_short', :count=>10),
product.errors[:title].join('; ')
给出:
<"translation missing: en, activerecord, errors, messages, too_short"> expected but was
<"is too short (minimum is 10 characters)">.
快速谷歌搜索苏ggests其他人正在使用activerecord.errors.messages.too_short,但显然它不起作用。有没有不同的方式来访问消息,我是否做了其他的错误?