mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Improve field error proc example in validations guide
This commit is contained in:
@@ -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">
|
||||
#{instance.error_message.join(',')}</span>).html_safe
|
||||
else
|
||||
%(#{html_tag}<span class="validation-error">
|
||||
#{instance.error_message}</span>).html_safe
|
||||
end
|
||||
errors = Array(instance.error_message).join(',')
|
||||
%(#{html_tag}<span class="validation-error"> #{errors}</span>).html_safe
|
||||
end
|
||||
</ruby>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user