class NotificationController < ApplicationController def index; end def show_notice flash.alert = %w[titi toto] if params[:multiple] == 'true' redirect_to notification_index_path, notice: 'this is a notice' end def show_alert flash.notice = ['italic message', 'normal message'] if params[:multiple] == 'true' redirect_to notification_index_path, alert: 'this is an alert' end def turbo_notice render_stream notice: "my notice ##{inc_count}" do |stream| stream.replace :turbo_placeholder, partial: 'turbo_placeholder' end end def turbo_alert render_stream alert: "alert, do the stuff right now ##{inc_count}" do |stream| stream.replace :turbo_placeholder2, partial: 'turbo_placeholder2' end end def turbo_more flash.now[:alert] = "alert, do the stuff right now ##{inc_count}" flash.now[:notice] = ["this is extra notice ##{inc_count}", 'one more time'] render_stream do |stream| # TODO: turbo_stream_elements which stores any append, prepend, replace, update, remove, before, after or refresh actions stream.replace(:turbo_placeholder, partial: 'turbo_placeholder') stream.replace(:turbo_placeholder2, partial: 'turbo_placeholder2') end end def turbo_none render_stream end private def inc_count @@count ||= 0 # rubocop:disable Style/ClassVars @@count += 1 # rubocop:disable Style/ClassVars end end