Skip to content

Instantly share code, notes, and snippets.

@brand-it
Created May 7, 2013 02:58
Show Gist options
  • Save brand-it/5529969 to your computer and use it in GitHub Desktop.
Save brand-it/5529969 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 formatted_errors(object = nil)
if object && object.errors.any?
return content_tag(:div, class: "ui_flash ui-widget ui-helper-clearfix", id: "error-messages") do
content_tag(:div, class: "ui-corner-all ui-state-error") do
content_tag(:span, "", class: "ui-icon ui-icon-left ui-icon-alert") +
content_tag(:span, "You have a total of " + pluralize(object.errors.count, "error") + " on this form") +
content_tag(:ul) do
object.errors.full_messages.collect {|msg| content_tag(:li, msg) }.join
end
end
end
end
return
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment