20 lines
576 B
Ruby
20 lines
576 B
Ruby
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance_tag|
|
|
fragment = Nokogiri::HTML.fragment(html_tag)
|
|
field = fragment.at('input,select,textarea')
|
|
|
|
html = if field
|
|
error_message = instance_tag.error_message.join(', ')
|
|
field['class'] = "#{field['class']}"
|
|
html = <<-HTML
|
|
<div class="field_with_errors">
|
|
#{fragment.to_s}
|
|
<p class="error-message">#{error_message.upcase_first}</p>
|
|
</div>
|
|
HTML
|
|
html
|
|
else
|
|
html_tag
|
|
end
|
|
|
|
html.html_safe
|
|
end |