Skip to content

Instantly share code, notes, and snippets.

@asssis
Last active February 21, 2019 17:26
Show Gist options
  • Save asssis/696244a6f901bb44c38fbf9a1afc9406 to your computer and use it in GitHub Desktop.
Save asssis/696244a6f901bb44c38fbf9a1afc9406 to your computer and use it in GitHub Desktop.
help_aplication
module ApplicationHelper
def flash_message
messages = ""
[:success, :warning, :danger].each {|type|
if flash[type]
if type == :success
messages = "<script type='text/javascript'> swal('Sucesso!', '#{flash[:success]}', 'success') </script>"
elsif type == :warning
messages = "<script type='text/javascript'> swal('Atenção!', '#{flash[:warning]}', 'warning') </script>"
elsif type == :danger
messages = "<script type='text/javascript'> swal('Falha!', '#{flash[:danger]}', 'error') </script>"
end
end
}
messages.html_safe
end
end
application
<%= flash_message %>
controle
flash[:danger] = 'Ação fiscal encerrada.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment