简体   繁体   English

Turbolinks似乎两次加载了我的页面

[英]Turbolinks seems to load my pages twice

I didn't notice it at first, but my application was behaving oddly: each time I clicked on a link generated by a link_to the page was loading twice. 一开始我没有注意到它,但是我的应用程序表现得很奇怪:每次我单击由link_to生成的链接时,页面都会加载两次。

Indeed, in the console: 实际上,在控制台中:

Started GET "/registrations" for 127.0.0.1 at 2013-11-18 16:58:30 -0800
Processing by RegistrationsController#index as HTML
  User Load (0.3ms)  SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", 1]]
  Registration Load (0.4ms)  SELECT "registrations".* FROM "registrations"
  Rendered registrations/index.html.erb within layouts/application (2.7ms)
  Rendered layouts/_alerts.html.erb (0.1ms)
Completed 200 OK in 7ms (Views: 5.4ms | ActiveRecord: 0.7ms)


Started GET "/registrations" for 127.0.0.1 at 2013-11-18 16:58:41 -0800
Processing by RegistrationsController#index as HTML
  User Load (0.5ms)  SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", 1]]
  Registration Load (0.3ms)  SELECT "registrations".* FROM "registrations"
  Rendered registrations/index.html.erb within layouts/application (1.9ms)
  Rendered layouts/_alerts.html.erb (0.1ms)
Completed 200 OK in 7ms (Views: 4.5ms | ActiveRecord: 0.8ms)

I was looking for a solution everywhere, but people kept referring to an issue with precompiled assets in a development environment, which is not my case. 我到处都在寻找解决方案,但是人们一直在指的是开发环境中预编译资产的问题,而我不是这种情况。

I "fixed" the problem by removing turbolinks from my Rails 4 app, but that's a really "brute force" workaround. 我通过从Rails 4应用程序中删除了涡轮链接来“解决”了这个问题,但这确实是一种“蛮力”解决方法。

Anyone here found himself in the same situation? 这里有人遇到同样的情况吗?

For reference, this was my <head> before removing turbolinks: 作为参考,这是删除turbolink之前的<head>

<head>
  <title>Title</title>
      <%= stylesheet_link_tag    "application", media: "all", "data-turbolinks-track" => true %>
    <%= stylesheet_link_tag  "//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css", media: "all" %>
      <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
    <%= javascript_include_tag "//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js" %>
      <%= csrf_meta_tags %>
</head>

I wonder if this could be related to this ticket 我想知道这是否与这张票有关

EDIT: That was the solution. 编辑:那是解决方案。 It is a known chrome bug. 这是一个已知的Chrome错误。 Updating your turbolinks gem will do the trick (it has been fixed in 1.3.1). 更新您的turbolinks gem将达到目的(在1.3.1中已修复)。

Solution: bundle update turbolinks 解决方案: bundle update turbolinks

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM