Last active
August 8, 2016 06:50
-
-
Save clauda/bedd3bb85db7d953f79c163bfd50a286 to your computer and use it in GitHub Desktop.
Toastr on Rails
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
... | |
<% unless flash.empty? %> | |
<script type="text/javascript"> | |
<% flash.each do |name, message| %> | |
toastr['<%= flash_for(name) %>']('<%= message %>'); | |
<% end %> | |
</script> | |
<% end %> | |
</body> | |
</html> |
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
module ApplicationHelper | |
FLASH_CLASSES = { | |
notice: "success", | |
alert: "warning", | |
error: "error", | |
infod: "info" | |
} | |
def flash_for name | |
FLASH_CLASSES[name.to_sym] | |
end | |
... | |
end |
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
application.js | |
`//= require toastr.min` | |
application.css | |
`*= require toastr.min` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment