Skip to content

Instantly share code, notes, and snippets.

@mdominiak
Created December 2, 2010 10:07
Show Gist options
  • Save mdominiak/725069 to your computer and use it in GitHub Desktop.
Save mdominiak/725069 to your computer and use it in GitHub Desktop.
error_messages_for
def error_messages_for(resource)
return "" if resource.errors.empty?
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
sentence = "Please fix the following errors:"
html = <<-HTML
<div class="error_explanation">
<div class="title">#{sentence}</div>
<ul>#{messages}</ul>
</div>
HTML
html.html_safe
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment