这里有两种显示AR记录的方法
# A: SHOW attribute name
nb:
errors:
format: "%{attribute} %{message}"
# B: HIDE attribute name
nb:
errors:
format: "%{message}"
我要 B:简单形式的隐藏该消息已在上下文中与输入框绑定。
为什么在Name can't be blank
足够的时候说can't be blank
。
当前,我们进行B:HIDE,因为它在UI中看起来很棒。但是在规格,控制台和日志中,我们是盲目的:
There was an error: can't be blank
#NOT HELPFUL, what attribute of what?
有了 A:SHOW ,我们得到了
There was an error: Name can't be blank
我都想要!有点贪心。我如何得到想要的东西? :)
我想到的是:如果用于简单形式的I18n查找上下文也具有format:
,那么该怎么办?
[i18n-debug] en.attributes.report_date => nil
[i18n-debug] nb.errors.format => "%{message}"
阿拉,不。
如果它首先有en.simpleform.errors.format
,那么我可以重写...那里可能还有其他更简单的想法。谢谢。