Inline Editing with Turbo Frames in Rails Discussion
Discussion for
Inline Editing with Turbo Frames in Rails
How would you abstract the polymorphic path if you wanted to use the inline edit/fields partials both in forms that are namespaced like in an admin route (e.g. a form at admin/settings/show) but also a form that is not namespaced (e.g. a form at articles/show). Not sure how to abstract these polymorphic routes so that they work in both cases.
Hey Lee, did you ever figure this out? I am currently struggling with the exact same issue.
Such a great tutorial. Small enhancement for the form validation errors.
In the _inline_fields.html.erb
I added my render for the validation_errors (similar to other tutorials) so that the flash message is shown on an invalid save.
<% frame_id = dom_id(f.object, "#{ attribute }_turbo_frame") %>
<%= turbo_frame_tag frame_id, class: "contents" do %>
<%= render "validation_errors", model: f.object %>
<div class="flex flex-row items-center mt-4">
<%= yield %>
<%= f.button class: "ml-2 btn-primary inline-action" do %>
Save <%= f.object.class.human_attribute_name(attribute) %>
<% end %>
<%= link_to "Cancel", polymorphic_path(f.object), class: "cancel inline-action" %>
</div>
<% end %>