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.

25 lines
604 B

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