All method: :delete links are failing

In my app all method: :delete links are failing. I tried to reinstall deps and node modules but i still get same error.

example error for notification

no route found for DELETE /notifications

but i have that route

notification_path DELETE /notifications/:id MyApp.Web.NotificationController :delete

this is delete button code. It is auto generated button

a class=“btn btn-danger btn-xs” data-confirm=“Are you sure?” data-csrf=“aSMKPHsAXQ8hKBxxLAQXazEdQG07JgAAYi3e1oi6QZlDt6cSXv3BCQ==” data-method=“delete” data-to=“/notifications/1” href=“#” rel=“nofollow”>Delete</a

my elixir version is 1.5.2
phoenix 1.3
erlang 20

What can cause that ?

UPDATE1 : I created a new phoenix app all links are works. I still cant figure what is wrong in existing app

1 Like

Those are different… The first tells you that there is no route for /notifications, while the second tells you you have a route for /notifications/:id, there is actually no contradiction as far as I can tell.

Can you please show the route-definition and the code which creates the button? Please put them in proper markdown code-blocks.

1 Like

Thanks I created a new app wit same name and i moved all codes except assets and everything is working. Problem some how releated with assets.
update: After i dig more problem is about jquery

Your problem is javascipt related, as I thought first… There is a blogpost about configuring bootstrap, jquery… and brunch.

I hope this helps…

2 Likes

Yes as u mention it is about js. i found problem on jquery_ujs. after i removed it from app.js everything is ok now

Notes to self in case I stumble here again:

From Phoenix.HTML issue #192 (button/link with :delete method?):

josevalim commented on Dec 22, 2017

We moved the creation of the form to javascript due to #151, so it should work as long as you make sure your javascript is up to date. Try removing the node_modules and compiling the JS again as mentioned in #167.

Workaround from Christian Kruse (ckruse) in Phoenix.HTML issue #151
(method: :delete link and inline form that it generates) if javascript is not an option:

ckruse commented on Jul 24, 2017

No need to apologize! This wasn’t meant as a complaint, I totally rely on your and Chris’ work and think you are doing a great job, thanks for all the hard work!

Regarding JS: I don’t think so. The code the old function generates looks as follows:

<form action="/admin/users/2" class="button" method="post">
  <input name="_method" type="hidden" value="delete">
  <input name="_csrf_token" type="hidden" value="Tho4KCZvAxk8ABEqATdgEzNfHz5EEAAAzrBqa+qWucpM8MUer2fqkg==">
  <button class="destructive-index-action" data-confirm="Sind Sie sicher?" type="submit">Löschen</button>
</form>

Christian’s custom button helpers:
ckruse/wwwtech.de - button.ex
Usage in layout

(Thank you Christian! I hope you don’t mind me sharing these.)

2 Likes