I like to use Turbo Frames in my existing Rails-App.
index.view looks now this way:
<h1>Projects List</h1>
<div><strong><%= pluralize(@projects.size, "Project") %> currently</strong></div>
<table class="table">
<thead>
<tr>
<th scope="col">Title</th>
<th scope="col">Description</th>
<th colspan="2" scope="col"></th>
</tr>
</thead>
<% @projects.each do |project| %>
<tr>
<td>
<%= link_to project.title, project %>
</td>
<td>
<%= project.description.truncate(40) %>
</td>
<td>
<%= link_to "Show", project, class: "link-info" %>
</td>
<td>
<%= turbo_frame_tag "edit_curr_project" do %>
<div>
<%= link_to "Edit", edit_project_path(project), class: "link-warning" %>
</div>
<% end %>
</td>
</tr>
<% end %>
</table>
<turbo-frame id="edit_curr_project">
<h1>Edit Project</h1>
<%= render "form", project: @project %>
</turbo-frame>
The update-method in the Controller-class:
def update
if @project.update(project_params)
redirect_to @project, notice: "Project updated successfully"
else
render :edit, status: :unprocessable_entity
end
end
Form (before update):
Error-message afterward:
It works in so far, that the entity gots updated. But “Content missing” in shown in the index-view and I need a browser-reload to see the recent update?
What I’m doing wrong?
How can this be fixed, so that the view updates?