2016-08-11 9 views
-1

나는 꽤 많은 게시물과 터보 링크 설명서를 읽었으며, 나는 아직 이해하지 못했다고 생각한다. 레일 5 애플리케이션에서 터보 링크를 완전히 끄려고합니다. 여기에 내가 레일에서 터보 링크를 완전히 비활성화하는 방법

  • stylesheet_link_tag에서 data-turbolinks-track을 제거하고 javascript_include_tag
  • application.html.erb 지금과 같은 application.js에서 //=require turbolinks의 모든 항목을 제거 gem 'trubolinks'

  • 을 제거 그것을

    1. 에 대해 갔다 방법 이

      <html> 
          <head> 
          <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
          <title><%= content_for?(:title) ? yield(:title) : "Website" %></title> 
          <meta name="description" content="<%= content_for?(:description) ? yield(:description) : "Website" %>"> 
          <%= stylesheet_link_tag 'application', media: 'all' %> 
          <%= stylesheet_link_tag params[:controller] %> 
          <%= javascript_include_tag 'application' %> 
          <%= javascript_include_tag :modernizr %>  
          <%= javascript_include_tag params[:controller] %> 
          <%= if(params[:action].eql?'contact') 
            javascript_include_tag 'https://www.google.com/recaptcha/api.js?onload=vcRecaptchaApiLoaded&render=explicit' , async: 'async', defer: 'defer' 
           end 
          %> 
          <%= csrf_meta_tags %> 
          </head> 
          <body data-turbolinks='false'> 
          ... 
          </body> 
      </html> 
      

      application.js 파일 :

      //= require jquery 
      //= require jquery_ujs 
      //= require lodash 
      //= require bootstrap-sprockets 
      //= require jquery.sticky 
      

      와 내가이 레이아웃의 모든 페이지에 사용하지 않도록 도움이 될 것입니다 body 태그에 data-turbolinks=false을 사용하여 생각

      @import "bootstrap-sprockets"; 
      @import "bootstrap"; 
      @import "font-awesome-sprockets"; 
      @import "font-awesome"; 
      @import "normalize-rails"; 
      @import "animate"; 
      .... 
      /* other css stuff */ 
      

      을 application.css. 하지만 그 페이지가

      <%= image_tag("pages/home/xyz_logo.png", class: "img-responsive", alt: "Customer") %>

      내가 스택 트레이스를 보면이 ActionView 변함없이 turbolinks에 따라 홈 페이지에이 라인에서 오류

      Sprockets::FileNotFound at/
      couldn't find file 'turbolinks' with type 'application/javascript' 
      Checked in these paths: 
          /Users/anadi/Code/website/app/assets/config 
          /Users/anadi/Code/website/app/assets/fonts 
          /Users/anadi/Code/website/app/assets/images 
          /Users/anadi/Code/website/app/assets/javascripts 
      

      와로드에 실패, 도움이되지 않았습니다 :

      sprockets (3.7.0) lib/sprockets/directive_processor.rb:182:in `rescue in block in process_directives' 
          sprockets (3.7.0) lib/sprockets/directive_processor.rb:179:in `block in process_directives' 
          sprockets (3.7.0) lib/sprockets/directive_processor.rb:178:in `process_directives' 
          sprockets (3.7.0) lib/sprockets/directive_processor.rb:83:in `_call' 
          sprockets (3.7.0) lib/sprockets/directive_processor.rb:68:in `call' 
          sprockets (3.7.0) lib/sprockets/processor_utils.rb:75:in `call_processor' 
          sprockets (3.7.0) lib/sprockets/processor_utils.rb:57:in `block in call_processors' 
          sprockets (3.7.0) lib/sprockets/processor_utils.rb:56:in `call_processors' 
          sprockets (3.7.0) lib/sprockets/loader.rb:134:in `load_from_unloaded' 
          sprockets (3.7.0) lib/sprockets/loader.rb:60:in `block in load' 
          sprockets (3.7.0) lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache' 
          sprockets (3.7.0) lib/sprockets/loader.rb:44:in `load' 
          sprockets (3.7.0) lib/sprockets/cached_environment.rb:20:in `block in initialize' 
          sprockets (3.7.0) lib/sprockets/cached_environment.rb:47:in `load' 
          sprockets (3.7.0) lib/sprockets/bundle.rb:23:in `block in call' 
          sprockets (3.7.0) lib/sprockets/utils.rb:196:in `dfs' 
          sprockets (3.7.0) lib/sprockets/bundle.rb:24:in `call' 
          sprockets (3.7.0) lib/sprockets/processor_utils.rb:75:in `call_processor' 
          sprockets (3.7.0) lib/sprockets/processor_utils.rb:57:in `block in call_processors' 
          sprockets (3.7.0) lib/sprockets/processor_utils.rb:56:in `call_processors' 
          sprockets (3.7.0) lib/sprockets/loader.rb:134:in `load_from_unloaded' 
          sprockets (3.7.0) lib/sprockets/loader.rb:60:in `block in load' 
          sprockets (3.7.0) lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache' 
          sprockets (3.7.0) lib/sprockets/loader.rb:44:in `load' 
          sprockets (3.7.0) lib/sprockets/cached_environment.rb:20:in `block in initialize' 
          sprockets (3.7.0) lib/sprockets/cached_environment.rb:47:in `load' 
          sprockets (3.7.0) lib/sprockets/base.rb:66:in `find_asset' 
          sprockets (3.7.0) lib/sprockets/base.rb:73:in `find_all_linked_assets' 
          sprockets (3.7.0) lib/sprockets/manifest.rb:134:in `block in find' 
          sprockets (3.7.0) lib/sprockets/manifest.rb:133:in `find' 
          sprockets-rails (3.1.1) lib/sprockets/railtie.rb:50:in `precompiled_assets' 
          sprockets-rails (3.1.1) lib/sprockets/railtie.rb:35:in `asset_precompiled?' 
          sprockets-rails (3.1.1) lib/sprockets/railtie.rb:250:in `block (3 levels) in <class:Railtie>' 
          sprockets-rails (3.1.1) lib/sprockets/rails/helper.rb:342:in `precompiled?' 
          sprockets-rails (3.1.1) lib/sprockets/rails/helper.rb:346:in `raise_unless_precompiled_asset' 
          sprockets-rails (3.1.1) lib/sprockets/rails/helper.rb:313:in `asset_path' 
          sprockets-rails (3.1.1) lib/sprockets/rails/helper.rb:85:in `block in resolve_asset_path' 
          sprockets-rails (3.1.1) lib/sprockets/rails/helper.rb:225:in `block in resolve_asset' 
          sprockets-rails (3.1.1) lib/sprockets/rails/helper.rb:224:in `resolve_asset' 
          sprockets-rails (3.1.1) lib/sprockets/rails/helper.rb:84:in `resolve_asset_path' 
          sprockets-rails (3.1.1) lib/sprockets/rails/helper.rb:74:in `compute_asset_path' 
          actionview (5.0.0) lib/action_view/helpers/asset_url_helper.rb:144:in `asset_path' 
          actionview (5.0.0) lib/action_view/helpers/asset_url_helper.rb:311:in `image_path' 
          actionview (5.0.0) lib/action_view/helpers/asset_tag_helper.rb:214:in `image_tag' 
      

      스프로킷은 여전히 ​​turbolinks js 또는 image_tag url이 기대하는 것처럼 보입니다. 나는 모든 링크 나 이미지에 data: { turbolinks: false }을 추가하는 것을 끝내고 싶지 않습니다. 이 작업을 수행하는 방법?

  • 답변

    0

    data-turbolinks-track => true을 추가하고, <body data-turbolinks='false'>을 보존. 오류가 발생하지 않고 예상대로 작동합니다.

    1
    1. gemfile에서 'turbolinks'줄을 제거하십시오.
    2. app/assets/javascripts/application.js에서 // required turbolinks를 제거하십시오.
    3. app/views/layouts/application.html.erb에서 두 개의 'data-turbolinks-track'=> true 해시 키/값 쌍 을 삭제합니다. 내가 잘못 아마도 그것 모두를 다시 활성화하고 있던
    +0

    공유 코드를 보면 이미 모든 작업을 완료했습니다! :-) –