There is a better way to do this than hijacking the frame missing event. You can respond from the server with a turbo stream with a script tag to perform a Turbo.visit. Works with the latest version of Turbo. https://github.com/hotwired/turbo-rails/pull/367#issuecomment-1601733561
Thanks @andrewhavens. That’s a really interesting solution! I’ve spent a little time thinking about it and I don’t agree that it is better. At least not for this specific use-case.
My gut reaction is that I like the frame-missing handler, because it doesn’t leak into the controller. The controller redirects on success as it always should.
I also want to push back on the idea that this is “hijacking the frame-missing event.” I would argue that this is precisely what the frame-missing event is for. If I’m wrong on that, I’d love to hear from the core team on it’s intended purpose. @dhh?
Again, I think your solution is very clever. I plan to bookmark the code you shared for future reference. For this use-case however, I’ll continue using the frame-missing handler.
Cheers!