Skip to content

Instantly share code, notes, and snippets.

@askehansen
Last active March 24, 2020 02:55
Show Gist options
  • Save askehansen/9545196 to your computer and use it in GitHub Desktop.
Save askehansen/9545196 to your computer and use it in GitHub Desktop.
Rails flash messages in toastr.js
<% unless flash.empty? %>
<script type="text/javascript">
<% flash.each do |f| %>
<% type = f[0].gsub('alert', 'error').gsub('notice', 'info') %>
toastr['<%= type %>']('<%= f[1] %>', '<%= type %>');
<% end %>
</script>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment