You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

50 lines
1.3 KiB

COUNT ||= 0
class NotificationController < ApplicationController
def index
logger.info '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 = ['<i>italic</i> <b>message</b>', 'normal <b>message</b>'] if params[:multiple] == 'true'
redirect_to notification_index_path, alert: 'this is an alert'
end
def turbo_notice
COUNT += 1
# TODO: render_stream (partial + flash -> flash.now + optional replace|append)
flash.now[:notice] = "coucou ##{COUNT}"
render turbo_stream: [
turbo_stream.replace(:flash, partial: 'layouts/components/flash')
]
end
def turbo_alert
COUNT += 1
flash.now[:alert] = "alert, do the stuff right now ##{COUNT}"
render turbo_stream: [
turbo_stream.replace(:flash, partial: 'layouts/components/flash')
]
end
def turbo_more
COUNT += 1
flash.now[:alert] = "alert, do the stuff right now ##{COUNT}"
flash.now[:notice] = ["this is extra notice ##{COUNT}", 'one more time']
render turbo_stream: [
turbo_stream.replace(:flash, partial: 'layouts/components/flash')
]
end
def turbo_none
COUNT += 1
render turbo_stream: [
turbo_stream.replace(:flash, partial: 'layouts/components/flash')
]
end
end