Skip to content

Instantly share code, notes, and snippets.

@allaire
Created October 22, 2012 23:03
Show Gist options
  • Save allaire/3935307 to your computer and use it in GitHub Desktop.
Save allaire/3935307 to your computer and use it in GitHub Desktop.
Field with errors
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
unless html_tag =~ /^<label/
%{<div class="field-with-errors">#{html_tag}<label for="#{instance.send(:tag_id)}" class="message">#{instance.error_message.first}</label> </div>}.html_safe
else
%{<div class="field-with-errors">#{html_tag}</div>}.html_safe
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment