Created
December 15, 2013 19:23
-
-
Save edymerchk/7976972 to your computer and use it in GitHub Desktop.
display_base_errors rails for flash msg
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 display_base_errors resource | |
return '' if (resource.errors.empty?) or (resource.errors[:base].empty?) | |
messages = resource.errors[:base].map { |msg| content_tag(:p, msg) }.join | |
html = <<-HTML | |
<div class="alert alert-error alert-block"> | |
<button type="button" class="close" data-dismiss="alert">×</button> | |
#{messages} | |
</div> | |
HTML | |
html.html_safe | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment