Skip to content

Instantly share code, notes, and snippets.

@rstormsf
Created October 17, 2015 05:20
Show Gist options
  • Save rstormsf/2e1aba4c1c473c07ed27 to your computer and use it in GitHub Desktop.
Save rstormsf/2e1aba4c1c473c07ed27 to your computer and use it in GitHub Desktop.
Mix Ruby and JS
- flash.each do |key, value|
javascript:
console.log("#{key}");
toastr.options = {
closeButton: true,
progressBar: true,
timeOut: 9000
};
var flash = {};
flash.message = "#{value}";
switch("#{key}"){
case 'alert':
flash.type = 'warning';
flash.header = 'Warning';
break;
case 'notice':
flash.type = 'success';
flash.header = 'Information';
break;
case 'error':
flash.type = 'error',
flash.header = 'Error';
break;
};
console.log(flash);
toastr[flash.type](flash.message, flash.header);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment