Skip to content

Instantly share code, notes, and snippets.

@stuartbain
Created November 2, 2013 12:01
Show Gist options
  • Save stuartbain/7278201 to your computer and use it in GitHub Desktop.
Save stuartbain/7278201 to your computer and use it in GitHub Desktop.
# https://coderwall.com/p/suyeew
# /app/helpers/devise_helper.rb
module DeviseHelper
def devise_error_messages!
return '' if resource.errors.empty?
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
sentence = I18n.t('errors.messages.not_saved',
count: resource.errors.count,
resource: resource.class.model_name.human.downcase)
html = <<-HTML
<div class="alert alert-error alert-block">
<button type="button" class="close" data-dismiss="alert">x</button>
<h4>#{sentence}</h4>
#{messages}
</div>
HTML
html.html_safe
end
end
@stuartbain
Copy link
Author

Devise Error Messages Twitter Bootstrap style

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment