Last active
August 29, 2015 14:04
-
-
Save CyberStrike/1a410509f23ea2f3ac97 to your computer and use it in GitHub Desktop.
Rails Flash Errors Customisation
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/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 |
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/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