Turbo Frame Redirect and Render

@clap Alexandru Clapou
Tue, 14 Oct 2025 20:37:09 +0000

Just solved this. Solid information Reload page with turbo frame after modal form submit and Ability to override frame-target from server response · Issue #257 · hotwired/turbo · GitHub

I wrapped my form inside another turbo-frame and I just created a custom Turbo Stream Action.

# frozen_string_literal: true

module TurboStreamActionsHelper
  def force_redirect(path)
    turbo_stream_action_tag :force_redirect, path: path
  end
end

Turbo::Streams::TagBuilder.prepend(TurboStreamActionsHelper)

then

create.turbo_stream.erb

<% if @valid_store %>
  <%= turbo_stream.force_redirect(edit_admin_store_path(@store)) %>
<% else %>
  <%= turbo_stream.replace "store_form" do %>
    <%= render "admin/stores/form", store: @store %>
  <% end %>
<% end %>

Hope it helps you.