link_to :confirm displays popup twice

I was having this same issue, and spent the better part of an hour looking into it. I found a solution in my situation, and I figured I would share it in case it helps...

My problem was that I had

config.assets.debug = true 

in config/environments/development.rb

Changing that line to

config.assets.debug = false

fixed the confirmation duplication for me. I found the relevant information in this rails guide to asset pipeline. Hope it helps!


It sounds like the confirmation handler Javascript in rails.js is being attached twice.

Could you be accidentally including two copies of rails.js via duplication of a javascript_include_tag helper?


I've been used to include the javascript_include_tag at the bottom of my haml-layout-file.

With Rails4 and Turbolinks it happens that:

  • Everything ok on the first load of a page (popup for confirmation appears only once)
  • Visiting another page -> popup occurs twice
  • Visiting one more page -> popup occurs three times
  • and so on
  • until I reload the page.

I solved the problem by moving the javascript_include_tag from the bottom into <head>


I'm using Rails 4 and none of the answers worked for me, however the following worked... I changed the line:

<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> 

to

<%= javascript_include_tag 'application', 'data-turbolinks-eval' => false %>.

https://github.com/rails/turbolinks/issues/244


I copy this solution from another post, but this is what worked for me (rails 5)

"remove jquery_ujs from your application.js as rails_ujs is enough for later rails version."

I had included: //= require jquery //= require jquery-ujs //= require rails-ujs

and after deleting it, all works fine. Solution from: Why am I getting a JQuery alert twice in Rails?