title: Rails turbolinks breaks css on loading
body: <p>Hopefully title is not misleading. My problem is - when using turbolinks and clicking on a link, the page, which gets loaded, seems to have no styling for a split second. Then, css loads and everything works fine. But this behavior is very user unfriendly.</p>
  
  <p>I can fix that by removing turbolinks, which works. But I rely on <code>turbolinks.visit</code> in some other parts of my code.</p>
  
  <p>I can also fix this by adding <code>method: :get</code> to every <code>=link_to</code> helper.</p>
  
  <p>Both methods are kind of 'hacky'. Is there a way to fix it the 'right way'?</p>
  
  <p>You can experience what I mean by clicking here on the logo (top left) -<a href="http://uzhindoma.eve-trader.net" rel="nofollow noreferrer">http://uzhindoma.eve-trader.net</a> (no modifications) and then on one of the three nav links (there is <code>method: :get</code>).</p>
  
  <p>I found <a href="https://stackoverflow.com/questions/23625635/the-stylesheet-broken-when-loading-different-layout-in-different-controllers?rq=1">this</a> similar SO question, but there is no solution provided. </p>
  
  <p>This is my application layout:</p>
  
  <pre><code>!!!
  
  %html
  %head
    %title Uzhindoma - Front
    = stylesheet_link_tag    'front', media: 'all', 'data-turbolinks-track' =&gt; true
    = stylesheet_link_tag "https://api.mapbox.com/mapbox-gl-js/v0.20.0/mapbox-gl.css", :rel =&gt; "stylesheet"
    = stylesheet_link_tag "https://fonts.googleapis.com/css?family=Open+Sans:400,600,700", :rel =&gt; "stylesheet"
    = csrf_meta_tags
  
  %body{class: "#{controller_name} #{action_name} g-body"}
    .g-content
      =render 'front/navigation/header'
      / Rendering errors
      %section
        -flash.each do |name, msg|
          =content_tag(:div, msg, class: "alert alert-#{name}")
      =yield
      =render 'front/navigation/footer'
  
  
  = javascript_include_tag "https://api.mapbox.com/mapbox-gl-js/v0.28.0/mapbox-gl.js"
  = javascript_include_tag 'front', 'data-turbolinks-track' =&gt; true
  = javascript_include_tag "https://widget.cloudpayments.ru/bundles/cloudpayments"
  </code></pre>
  
  <p>And here is my front.js</p>
  
  <pre><code>// Place all the behaviors and hooks related to the matching controller here.
  // All this logic will automatically be available in application.js.
  // You can use CoffeeScript in this file: http://coffeescript.org/
  
  //= require jquery3
  //= require jquery_ujs
  //= require_tree ../../../vendor/assets/javascripts/front/custom/.
  
  
  //= require_self
  //= require_tree ../../../app/assets/javascripts/front/.
  //= require turbolinks
  </code></pre>
  
  <p>If I remove <code>//= require turbolink</code>, then linking works just fine, but I won't get some redirects (which rely on <code>TurboLinks.visit</code> method)</p>
  
  <p>To decide, which layout to use with which controller, I've got following controller structure:
  <code>controllers/application_controller.rb</code>
  <code>controllers/front_controller.rb</code>
  <code>controllers/admin_controller.rb</code>
  <code>controllers/front/...</code>
  <code>controllers/admin/...</code></p>
  
  <p>application_controller:</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
    # Prevent CSRF attacks by raising an exception.
    # For APIs, you may want to use :null_session instead.
    protect_from_forgery with: :exception
  
    layout :layout_by_resource
  
    protected
  
    def layout_by_resource
      if devise_controller?
        "front"
      end
    end
  end
  </code></pre>
  
  <p>front_controller:</p>
  
  <pre><code>class FrontController &lt; ApplicationController
      layout 'front'
  end
  </code></pre>
  
  <p>admin_controller:</p>
  
  <pre><code>class AdminController &lt; ApplicationController
      layout "admin"
  end
  </code></pre>