Created
December 2, 2010 10:07
-
-
Save mdominiak/725069 to your computer and use it in GitHub Desktop.
error_messages_for
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
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