jQuery-turbolinks - link_to confirm: pops up several times times in Rails
jquery-turbolinks should not really be necessary; my apps work correctly without it...
Are you sure that:
- you have the
javascript_include_tag ...
line in the<head>
part of your html? - you have only one
javascript_include_tag ...
line?
background:
The problem you have is that the jquery_ujs setup is called on every turbolinks page load resulting in duplicated handlers being installed.Since a turbolinks page load just replaces the <body>
part of the document you must be doing something inside your <body>
that triggers jquery_ujs setup...
See also these answers: https://stackoverflow.com/a/18260585/211060 and https://stackoverflow.com/a/4475479/211060
Maybe you're including multiple copies of rails.js?
Checkout this post and see if solves your problem.
You should be passing the id
of the recipe
being deleted as a parameter to the recipe_path
, probably as follows:
= link_to "Delete", recipe_path(recipe), method: :delete, data: {confirm: "Are you sure?" }, class: "btn btn-default"
Without an object being passed, I am guessing it is deleting many records.