rails turbyl提交多次,当turbolink gem处于活动状态时,remote:不活动

时间:2014-04-25 11:47:07

标签: ruby-on-rails ruby-on-rails-4 form-for turbolinks

所以我有一个基本的form_for(在我的情况下,我使用simple_form_for,但两种形式的行为是相同的)。因此,通过导航我的网站,并转到表单所在的页面,添加一些数据并提交,它将在数据库中保存两次数据。

点击一次提交后,将有2 3或4个提交。 对于每次提交,我都会收到此错误消息,但是对于上次提交,我没有得到它,代码正在执行所谓的操作。

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

我必须将data-no-turbolink='true'添加到我的<a> tag中,以防止表单执行其操作。

问题是我想在这些页面中使用turbolinks,因为它使一切都超级快。

如有必要,我会发布表格代码。

1 个答案:

答案 0 :(得分:0)

表单多次提交,因为我正在使用Google代码管理器表单提交跟踪。

<!-- 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>
相关问题