Ruby on Rails

Sdílet
Vložit
  • čas přidán 8. 05. 2024
  • How to redirect from a form that is inside a turbo frame?
    This is a very specific question that you will definitely have after working with Hotwire for some time.
    There are many possible solutions, some better that the others.
    Let's explore the problem and different strategies to solving it:
    1. add and click a hidden link
    2. new turbo stream redirect action
    3. adding turbo stream helpers and params
    0:00 Introduction
    0:49 Full page redirect does not work?
    4:00 Break out of turbo frame does not work?
    4:55 turbo stream hidden link
    10:50 do not cache hidden link
    12:42 Create a New Turbo Stream Action (best redirect)
    14:56 A Turbo Stream action with params (more complicated)
    19:50 Final demo
    Episode source code: github.com/corsego/151-dialog...
    Based on this blogpost: blog.corsego.com/custom-turbo...

Komentáře • 6

  • @kerlq3713
    @kerlq3713 Před 21 dnem

    12:42 did it for me!
    Thank you very much

  • @remotronic
    @remotronic Před 5 měsíci +1

    Useful, thanks

  • @njongefred
    @njongefred Před 5 měsíci

    Thanks for this

  • @yaroslavbozhak9107
    @yaroslavbozhak9107 Před 5 měsíci +1

    Thanks 👍

  • @mateuszbialowas
    @mateuszbialowas Před 5 měsíci +1

    Unfortunately in this approach, you are losing the flash message.

    • @SupeRails
      @SupeRails  Před 5 měsíci +2

      Actually you can!
      Here's how:
      flash[:notice] = "Comment created."
      flash.keep(:notice)