I am writing a rails app and making use of turbo frame. I have done a very similar thing in a previous app and didn't have this same problem.
All the content that changes is in a turbo frame called content, so that the sidebar and header are not touched whenever the page changes. Within this I have two further turbo frames, that I wanted to give SRC attributes so that something loads when the pages is first visited but can then be replaced as the user filters a table. For some reason these pages never load.
Looking at the terminal there doesn't seem to be any call to the server, and if I visit the path generated in the html element separately it seems to work so no idea why it is not being called. I assume it's something to do with the frames being nested but as I said I have done this before with no issues.
If I add a loading animation into the frame that works, but is never replaced as it should be by the src path.
My 'specs/index.html.erb' file
<%= turbo_frame_tag :content do %>
<div class="content_window">
<%= button_to new_style_path, :method => :get do %>
<i class="icon">add</i> New Style
<% end %> <!-- new style button -->
<%= turbo_frame_tag :spec do %>
<h1>Latest Spec <%= @specs.first.name %></h2>
<% end %> <!-- spec turbo frame -->
<%= turbo_frame_tag :spec_table, src: spec_table_path do %>
<div class="single4"></div>
<% end %>
</div> <!-- content_window -->
<% end %> <!-- content turbo frame -->
My 'specs/spec_table.html.erb' file
<%= turbo_frame_tag :spec_table do %>
<table class="spec_list">
<tr>
<th>Style Number</th>
<th>Style Name</th>
<th>Created on</th>
</tr>
<% @specs.each do |spec| %>
<tr onclick="location.href='<%= style_path(spec.id) %>'">
<td><%= spec.style_num %></td>
<td><%= spec.name %></td>
<td><%= spec.created_at %></td>
</tr>
<% end %>
</table>
<% end %>
Spec Controller
class SpecsController < ApplicationController
before_action :set_spec, only: %i[show]
def index
@specs = Style.all.sort_by(&:style_num)
end
def show
end
def spec_table
@specs = Style.all.sort_by(&:style_num)
end
Routes
Rails.application.routes.draw do
get "specs/index", to: "specs#index", as: "specs"
get "specs/spec_table", to: "specs#spec_table", as: "spec_table"
get "specs/:id", to: "specs#show", as: "spec"
get "pages/dash", to: "pages#dash", as: "dash"
resources :styles
devise_for :users
devise_scope :user do
match '/sessions/user', to: 'devise/sessions#create', via: :post
end
get 'pages/index'
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
# Defines the root path route ("/")
root "pages#index"
end
I see there is a similar question previously which mentions JS bundling, which I don't know anything about. Import maps has seemingly served me fine, and as I said this has worked on another app I am working on, so assume that's not the issue.