Method: :delete is not working in multiple locations in my phoenix app

thanks guys got it working, this was a brunch issue when I added subfolders to my project in assets and priv just need to read a bit on brunch

1 Like

Sorry for resurrecting this @Almog but could you expand on the fix? I too am having issues that sound similar to yours

Make sure you are properly importing phoenix_html in your entry JS file (usually app.js): import "phoenix_html". The :delete method needs it to work properly.

I really don’t remember the exact fix but I can say is that just check brunch all my issues was how that was setup up, personally I would prefer not to use it at all

Here is an example that works for me:

              <%= link(to: Routes.user_session_path(@conn, :delete), method: :delete, data: [confirm: "Are you sure?"], class: "no-underline px-4 py-2 block text-black hover:bg-gray-light") do %>
                Logout
              <% end %>

The method: :delete needs to be outside user_session_path. most of the places I’ve seen being explaining or with from people having the same issue, the put it inside, like this: Routes.user_session_path(@conn, :delete, method: :delete)

or… at least it works for me :smiley:

PS:

You do need to have:

import "phoenix_html"

in your app.js