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.

19 lines
586 B

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
  1. # interaction with the flash message
  2. class FlashController < ApplicationController
  3. def index; end
  4. def redirect_with_notice = redirect_to flash_path, notice: build_message(:notice)
  5. def redirect_with_alert = redirect_to flash_path, alert: build_message(:alert)
  6. def turbo_notice
  7. flash[:notice] = 'From Turbo'
  8. flash[:alert] = 'Alert Turbo'
  9. render turbo_stream: flash_stream
  10. end
  11. private
  12. def build_message(type_of_message)
  13. session[:flash_iteration] = session[:flash_iteration].to_i + 1
  14. "this is #{type_of_message} ##{session[:flash_iteration]}"
  15. end
  16. end