# interaction with the flash message class FlashController < ApplicationController def index; end def redirect_with_notice = redirect_to(flash_path, notice:) def redirect_with_alert = redirect_to(flash_path, alert:) def redirect_with_both flash[:notice] = notice flash[:alert] = alert redirect_to flash_path end def from_render session[:flash_iteration] = session[:flash_iteration].to_i + 1 flash.now[:notice] = "From Render #{session[:flash_iteration]}" flash.now[:alert] = "Alert Render #{session[:flash_iteration]}" logger.info(flash.object_id) render :index end def from_turbo flash.now[:notice] = 'From Turbo' flash.now[:alert] = 'Alert Turbo' render turbo_stream: flash_stream end private def notice = build_message(:notice) def alert = build_message(:alert) def build_message(type_of_message) session[:flash_iteration] = session[:flash_iteration].to_i + 1 "this is #{type_of_message} ##{session[:flash_iteration]}" end end