Skip to content

Commit e8502ed

Browse files
committed
fix guide with field_with_error proc example
1 parent abb38fe commit e8502ed

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

guides/source/active_record_validations_callbacks.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,8 +953,12 @@ Below is a simple example where we change the Rails behavior to always display t
953953

954954
```ruby
955955
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
956-
errors = Array(instance.error_message).join(',')
957-
%(#{html_tag}<span class="validation-error">&nbsp;#{errors}</span>).html_safe
956+
if html_tag =~ /\<label/
957+
html_tag
958+
else
959+
errors = Array(instance.error_message).join(',')
960+
%(#{html_tag}<span class="validation-error">&nbsp;#{errors}</span>).html_safe
961+
end
958962
end
959963
```
960964

0 commit comments

Comments
 (0)