Skip to content

Instantly share code, notes, and snippets.

@ptzn
Created April 19, 2010 13:36
Show Gist options
  • Save ptzn/371051 to your computer and use it in GitHub Desktop.
Save ptzn/371051 to your computer and use it in GitHub Desktop.
def error_messages_for(object)
object = instance_variable_get("@#{object}")
return if object.errors.empty?
result = "<div id=\"errorExplanation\"><h2>The following errors prohibited this form from being saved:</h2><ul>"
object.errors.full_messages.each { |msg| result << "<li>#{msg}</li>" }
result << "</ul></div>"
result.html_safe
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment