All threads / Inline Editing with Turbo Frames in Rails Discussion
Ask A Question

Notifications

You’re not receiving notifications from this thread.

Inline Editing with Turbo Frames in Rails Discussion

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.

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 %>

Chris why does the source code for the episode not match the video at all?

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 70,078+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2023 GoRails, LLC. All rights reserved.