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.

29 lines
734 B

2 months ago
2 months ago
2 months ago
2 months ago
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 redirect_with_notice = redirect_to(flash_path, notice:)
  5. def redirect_with_alert = redirect_to(flash_path, alert:)
  6. def render_notice
  7. flash[:notice] = 'From Render'
  8. flash[:alert] = 'Alert Render'
  9. render :index
  10. end
  11. def turbo_notice
  12. flash[:notice] = 'From Turbo'
  13. flash[:alert] = 'Alert Turbo'
  14. render turbo_stream: flash_stream
  15. end
  16. private
  17. def notice = build_message(:notice)
  18. def alert = build_message(:alert)
  19. def build_message(type_of_message)
  20. session[:flash_iteration] = session[:flash_iteration].to_i + 1
  21. "this is #{type_of_message} ##{session[:flash_iteration]}"
  22. end
  23. end