From 4e00e8e91637e117f702ec277a5db1fd087cb347 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?=
 <rafaelmfranca@gmail.com>
Date: Tue, 20 Nov 2012 14:59:50 -0800
Subject: Merge pull request #8280 from asanghi/fix_guide_field_with_error_proc

fix guide with field_with_error proc example

[ci skip]
---
 .../guides/source/active_record_validations_callbacks.textile     | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

(limited to 'railties/guides')

diff --git a/railties/guides/source/active_record_validations_callbacks.textile b/railties/guides/source/active_record_validations_callbacks.textile
index 15d24f9ac1..d2a445b508 100644
--- a/railties/guides/source/active_record_validations_callbacks.textile
+++ b/railties/guides/source/active_record_validations_callbacks.textile
@@ -901,8 +901,12 @@ Below is a simple example where we change the Rails behavior to always display t
 
 <ruby>
 ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
-  errors = Array(instance.error_message).join(',')
-  %(#{html_tag}<span class="validation-error">&nbsp;#{errors}</span>).html_safe
+  if html_tag =~ /\<label/
+    html_tag
+  else
+    errors = Array(instance.error_message).join(',')
+    %(#{html_tag}<span class="validation-error">&nbsp;#{errors}</span>).html_safe
+  end
 end
 </ruby>
 
-- 
cgit v1.2.3