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,但顯然它不起作用。有沒有不同的方式來訪問消息,我是否做了其他的錯誤?