Skip to content

Instantly share code, notes, and snippets.

@dustMason
Forked from t2/application.rb
Last active December 18, 2015 17:19
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dustMason/5817510 to your computer and use it in GitHub Desktop.
Save dustMason/5817510 to your computer and use it in GitHub Desktop.
Rails 3 ActionView override for Foundation 4 field error styles.
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
@dustMason
Copy link
Author

Note that this wraps labels and inputs in their own <div>'s. This is fine for my project, YMMV

@tough-griff
Copy link

This helped me out a bunch, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment