提交 0186c5dc 编写于 作者: C Carlos Antonio da Silva

Improve field error proc example in validations guide

上级 84bd203b
...@@ -901,13 +901,8 @@ Below is a simple example where we change the Rails behavior to always display t ...@@ -901,13 +901,8 @@ Below is a simple example where we change the Rails behavior to always display t
<ruby> <ruby>
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
if instance.error_message.kind_of?(Array) errors = Array(instance.error_message).join(',')
%(#{html_tag}<span class="validation-error">&nbsp; %(#{html_tag}<span class="validation-error">&nbsp;#{errors}</span>).html_safe
#{instance.error_message.join(',')}</span>).html_safe
else
%(#{html_tag}<span class="validation-error">&nbsp;
#{instance.error_message}</span>).html_safe
end
end end
</ruby> </ruby>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册