Joined August 2017
·

matiasfmolinari

·

Here's an alternative with iziToast:

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
Achievements
1 Karma
0 Total ProTip Views