Skip to content
Browse files

Improve field error proc example in validations guide

  • Loading branch information...
1 parent eb171fa commit 79a0488ceaa8bcf7135909872274ed09a88b4bae @carlosantoniodasilva carlosantoniodasilva committed Jan 25, 2012
Showing with 2 additions and 7 deletions.
  1. +2 −7 railties/guides/source/active_record_validations_callbacks.textile
View
9 railties/guides/source/active_record_validations_callbacks.textile
@@ -901,13 +901,8 @@ 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|
- if instance.error_message.kind_of?(Array)
- %(#{html_tag}<span class="validation-error">&nbsp;
- #{instance.error_message.join(',')}</span>).html_safe
- else
- %(#{html_tag}<span class="validation-error">&nbsp;
- #{instance.error_message}</span>).html_safe
- end
+ errors = Array(instance.error_message).join(',')
+ %(#{html_tag}<span class="validation-error">&nbsp;#{errors}</span>).html_safe
end
</ruby>

0 comments on commit 79a0488

Please sign in to comment.
Something went wrong with that request. Please try again.