0

I follow this reference Delete link sends Get request instead of Delete Rails 7

But looks like It is not working for me

I have this link inside a turbo_frame

<%= link_to t("delete"), post_path(post), method: :delete, class: "font-medium text-red-600 underline hover:no-underline hover:text-red-500", data: { confirm: t("are_you_sure") , turbo: false } %>

And the confirm is not appearing and also the request is a GET

I tested adding a byebug on the destroy action and is not triggered when I press the link.

Instead this works

<%= link_to t("delete"), post, method: :delete, class: "font-medium text-red-600 underline hover:no-underline hover:text-red-500", data: { turbo_confirm: t("are_you_sure"), turbo_method: :delete } %>

But I need a full page redirect in order to redirect users to the posts_path

Ideas why the confirm and the disable turbo is pointing to the GET an not to the delete ?

Here is the post_controller destroy method

 def destroy
    @post.destroy

    respond_to do |format|
      format.html { redirect_to posts_url, status: :see_other }
    end
  end
7
  • seems relevant: github.com/rails/rails/issues/41676 Commented May 9, 2024 at 12:42
  • 1
    Does this answer your question? Rails 7 - link_to with method :delete still performs GET request, or This? It seems the preferred method these days it to use button_to Commented May 9, 2024 at 15:21
  • 1
    BTW turbolinks != turboframe Commented May 9, 2024 at 20:14
  • Nope, all the time Im redirected to the post show with content missing when I use the button with turbo enabled. And when turbo is false, the confirm do not shows .. Commented May 9, 2024 at 21:04
  • 2
    just use data: {turbo_frame: "_top"} turbo.hotwired.dev/reference/… Commented May 10, 2024 at 7:23

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.