module ApplicationHelper
def flash_messages
flash_messages = []
flash.each do |type, message|
return unless message
level = case type
when 'notice' then 'success'
when 'alert' then 'error'
when 'info' then 'info'
when 'warn' then 'warn'
else
# Log and notify that a weird flash type has appeared.
'info'
end
js = javascript_tag %{iziToast.#{level}({ title: '#{level.capitalize}:', message: "#{message}" });}
flash_messages << js
end
flash_messages.join('/n').html_safe
end
end
Here's an alternative with iziToast: