Skip to content

Instantly share code, notes, and snippets.

@brand-it
Created April 19, 2014 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brand-it/11097979 to your computer and use it in GitHub Desktop.
Save brand-it/11097979 to your computer and use it in GitHub Desktop.
module ApplicationHelper
# Basic function with this if you have any object.errors that you wanted formated you just call this method and it will handle the formating
def error_summery( object )
return unless object.errors.any?
# Build the messages li
messages = []
object.errors.full_messages.each do |msg|
messages << content_tag(:li, msg)
end
content_tag(:div, "Please review the errors below", class: 'alert alert-danger') +
content_tag(:div, content_tag(:ul, messages.join("").html_safe), class: 'alert alert-danger')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment