Question

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.

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.

Anyone here found himself in the same situation?

For reference, this was my <head> before removing turbolinks:

<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>
Was it helpful?

Solution

I wonder if this could be related to this ticket

EDIT: That was the solution. It is a known chrome bug. Updating your turbolinks gem will do the trick (it has been fixed in 1.3.1).

Solution: bundle update turbolinks

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top