提交 e8502eda 编写于 作者: A Aditya Sanghi

fix guide with field_with_error proc example

上级 abb38fea
...@@ -953,8 +953,12 @@ Below is a simple example where we change the Rails behavior to always display t ...@@ -953,8 +953,12 @@ 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 html_tag =~ /\<label/
html_tag
else
errors = Array(instance.error_message).join(',') errors = Array(instance.error_message).join(',')
%(#{html_tag}<span class="validation-error">&nbsp;#{errors}</span>).html_safe %(#{html_tag}<span class="validation-error">&nbsp;#{errors}</span>).html_safe
end
end end
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册