Skip to content

Instantly share code, notes, and snippets.

@blrB
Created January 20, 2022 10:19
Show Gist options
  • Save blrB/1b0e1d44f31df1d1c9932985471ec3b3 to your computer and use it in GitHub Desktop.
Save blrB/1b0e1d44f31df1d1c9932985471ec3b3 to your computer and use it in GitHub Desktop.
Turbo eager-loaded frame issue (ruby 3.1.0, rails 7.0.1, turbo-rails (1.0.1))
# /app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
def page
end
def page_redirect
redirect_to page_path, status: :moved_permanently
end
def page_post_redirect
redirect_to page_path, status: :moved_permanently
end
def src_content
end
end
<!-- /app/views/application/page.html.erb -->
<div id="demo-page">
<p>page body start:</p>
<p><%= Time.now.strftime('%H:%M:%S') %>
</p>
<%= link_to 'GET redirect', page_redirect_path %>
<%= link_to 'POST redirect', page_post_redirect_path, data: { turbo_method: :post } %>
<div style="border: solid;">
<%= turbo_frame_tag id="src_content", src: src_content_path do %>
Loading...
<% end %>
</div>
<p>page body end.</p>
</div>
# /config/routes.rb
Rails.application.routes.draw do
get :page, controller: :application
get :page_redirect, controller: :application
post :page_post_redirect, controller: :application
get :src_content, controller: :application
end
<!-- /app/views/application/src_content.html.erb -->
<%= turbo_frame_tag :src_content do %>
<p>turbo-frame body start:</p>
<p><%= Time.now.strftime('%H:%M:%S') %>
</p>
<p>turbo-frame body end.</p>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment