Created
May 23, 2013 12:19
-
-
Save oelmekki/5635663 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 | |
# Format errors for display. | |
# Resource may be a model or an handler - just anything including ActiveModel::Validations | |
# | |
# @param [Object] resource the source of errors | |
# @return [String] the error html | |
def error_messages_for_handler( resource ) | |
message = <<-EOS | |
<div id="error_explanation"> | |
<ul> | |
%s | |
</ul> | |
</div> | |
EOS | |
lines = resource.errors.full_messages.map { |msg| '<li>%s</li>' % msg }.join( "\n" ) | |
( message % lines ).html_safe | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment