Skip to content

Commit

Permalink
Improve field error proc example in validations guide
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosantoniodasilva committed Jan 25, 2012
1 parent eb171fa commit 79a0488
Showing 1 changed file with 2 additions and 7 deletions.
Expand Up @@ -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>

Expand Down

0 comments on commit 79a0488

Please sign in to comment.