Skip to content

Instantly share code, notes, and snippets.

@gbalbuena
Forked from dustMason/application.rb
Last active February 3, 2016 14:03
Show Gist options
  • Save gbalbuena/9023171 to your computer and use it in GitHub Desktop.
Save gbalbuena/9023171 to your computer and use it in GitHub Desktop.
Rails Error field template bootstrap 3
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
html = %(<div class="error">#{html_tag})
html += %(<small>#{instance.error_message.to_a.to_sentence}</small>).html_safe unless html_tag =~ /^<label/
html += %(</div>)
html.html_safe
end
# ...
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
html = %(<div class="error">#{html_tag})
html += %(&nbsp;<small style='color: red;'>#{instance.error_message.to_a.to_sentence}</small>).html_safe unless html_tag =~ /^<label/
html += %(</div>)
html.html_safe
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment