Skip to content

Instantly share code, notes, and snippets.

@edymerchk
Created December 15, 2013 19:23
Show Gist options
  • Save edymerchk/7976972 to your computer and use it in GitHub Desktop.
Save edymerchk/7976972 to your computer and use it in GitHub Desktop.
display_base_errors rails for flash msg
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">&#215;</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