Skip to content

Instantly share code, notes, and snippets.

@CyberStrike
Last active August 29, 2015 14:04
Show Gist options
  • Save CyberStrike/1a410509f23ea2f3ac97 to your computer and use it in GitHub Desktop.
Save CyberStrike/1a410509f23ea2f3ac97 to your computer and use it in GitHub Desktop.
Rails Flash Errors Customisation
'app/views/layouts/_flash_errors.slim'
- flash.each do |type, message|
.alert class="#{flash_class(type)} alert-dismissible"
button.close data-dismiss='alert'
| ×
strong
.text-center= message
'app/helpers/application_helper.rb'
module ApplicationHelper
# Give us a class based on the flash type we pass it.
def flash_class(type)
case type
when :notice
'alert-info'
when :success
'alert-success'
when :error
'alert-danger'
when :alert
'alert-warning'
else
'alert-info'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment