Turbo-Location header: redirect a frame submission to a new URL

159
0

When a form submits inside a Turbo Frame, a normal redirect can sometimes feel odd (especially if the redirect response doesn’t include the matching frame). A clean approach is to set the Turbo-Location header for Turbo requests. Turbo interprets it as a top-level navigation, so the browser URL updates and you land on the show page as expected. I use this for “create in modal then go to show” flows: validate and save in the controller, then either (a) replace the modal with errors (422), or (b) set Turbo-Location and return head :see_other. This keeps the flow predictable and avoids writing JS to close modals or manually visit URLs.