Created
May 7, 2013 02:58
-
-
Save brand-it/5529969 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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