我一开始并没有注意到它,但我的应用程序表现得很奇怪:每次点击link_to
生成的链接时,页面都会加载两次。
确实,在控制台中:
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)
我到处寻找解决方案,但人们在开发环境中一直提到预编译资产的问题,这不是我的理由。
我通过从我的Rails 4应用程序中删除turbolink来“解决”这个问题,但这是一个非常“强力”的解决方法。
这里有人发现自己处于同样的境地吗?
作为参考,在移除turbolinks之前,这是我的<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>
答案 0 :(得分:0)
我想知道这是否与this ticket
有关 编辑:那就是解决方案。这是一个已知的铬虫。更新你的turbolinks
gem将起到作用(已在1.3.1中修复)。
解决方案: bundle update turbolinks