質問

So I have a basic form_for(in my case I use simple_form_for, but the behaviour is the same for both forms). So by navigating my website, and going to the page where the form is, and adding some data and submitting it, it will saved the data twice in the database.

After click once on submit there will be 2 3 or 4 submissions. For every submission I get this error message, but for the last submit I don't get it and the code is doing what is suppose to.

Redirected to [...]/projects/2/keywords/new
Completed 302 Found in 13ms (ActiveRecord: 3.1ms)
[2014-04-25 12:17:34] ERROR Errno::ECONNRESET: Connection reset by peer

I had to add data-no-turbolink='true' into my <a> tag to prevent the form doing what it does.

The problem is that I want to use turbolinks in those pages, because it makes everything super fast.

If necessary I will post my forms code.

役に立ちましたか?

解決

The form was submitting multiple times because I was tracking with google tag manager forms submissions.

<!-- Google Tag Manager -->
 <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-PQZJ2T"
 height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
 <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
 new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
 j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
 '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
 })(window,document,'script','dataLayer','GTM-PQZJ2T');</script>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top