Created
July 5, 2013 08:28
-
-
Save zirosas/5932940 to your computer and use it in GitHub Desktop.
Devise Error Messages for Bootstrap
This file contains hidden or 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
/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">×</button> | |
<strong>#{sentence}</strong> | |
#{messages} | |
</div> | |
HTML | |
html.html_safe | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment