如何在 Rails 6 中禁用 TurboLinks?

How to disable TurboLinks in Rails 6?

所以我面临这个问题,我的服务器确实从客户端的请求中检索了正确的数据,并将此数据发送到浏览器,我可以清楚地看到它对浏览器可用 (CTRL+SHIFT+C >网络 > my_request)。但是,浏览器不会刷新。所以我现在看到的是上一页的数据。搜索了一下后,我确定它是由 TurboLinks 引起的,然后我尝试将其禁用 here or 。然而浏览器仍然不会刷新并显示新获取的数据。我做的最后一件事是 grep -r turbolink * 在我的项目目录中,它给了我以下内容:

app/views/layouts/_dashboard_menu_certified.html.erb:          <%= submit_tag("Apply", {'data-turbolinks': false}) %>
log/development.log:    21:     <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
node_modules/@rails/webpacker/README.md:<%= javascript_packs_with_chunks_tag 'calendar', 'map', 'data-turbolinks-track': 'reload' %>
node_modules/@rails/webpacker/README.md:<script src="/packs/vendor-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
node_modules/@rails/webpacker/README.md:<script src="/packs/calendar~runtime-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
node_modules/@rails/webpacker/README.md:<script src="/packs/calendar-1016838bab065ae1e314.js" data-turbolinks-track="reload"></script>
node_modules/@rails/webpacker/README.md:<script src="/packs/map~runtime-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
node_modules/@rails/webpacker/README.md:<script src="/packs/map-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
node_modules/@rails/webpacker/CHANGELOG.md:<%= stylesheet_packs_with_chunks_tag 'calendar', 'map', 'data-turbolinks-track': 'reload' %>
node_modules/@rails/webpacker/CHANGELOG.md:<%= javascript_packs_with_chunks_tag 'calendar', 'map', 'data-turbolinks-track': 'reload' %>
node_modules/@rails/webpacker/CHANGELOG.md:<script src="/packs/vendor-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
node_modules/@rails/webpacker/CHANGELOG.md:<script src="/packs/calendar~runtime-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
node_modules/@rails/webpacker/CHANGELOG.md:<script src="/packs/calendar-1016838bab065ae1e314.js" data-turbolinks-track="reload"></script>
node_modules/@rails/webpacker/CHANGELOG.md:<script src="/packs/map~runtime-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
node_modules/@rails/webpacker/CHANGELOG.md:<script src="/packs/map-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>

我错过了什么吗? 干杯。

编辑:

<div class="col-sm-6 card">
      <% @res.each do |tool, histories| %>
        <div class="chart">
          <div class="card-header">
            <div class="nav nav-pills card-header-pills">
              <%= tool %>
            </div>
          </div>
          <div class="card-body">
            <div id="<%= tool %>" class=""></div>
            <script>
              new Morris.Line({
              element: "<%= tool %>",
              data: [
                <% histories.each do |history| %>
                  { date: '<%= history.date %>', value: <%= history.uptodate %>, value2: <%= history.outdated %>, value3: <%= history.error %>},
                <% end %>
              ],
              xkey: 'date',
              ykeys: ['value', 'value2', 'value3'],
              labels: ['UpToDate', 'OutDated', 'Error']
              })
            </script>
          </div>
        </div>
      <% end %>
</div>
  1. Gemfile
  2. 中删除 gem 'turbolinks', '~> 5'
  3. app/assets/javascript/application.js
  4. 中删除 //= require turbolinks
  5. app/views/layouts/application.html.erb
  6. 中删除 , 'data-turbolinks-track': 'reload' (x2)
  7. 运行 yarn remove turbolinks
  8. 运行 rails tmp:cache:clear

步骤 4 是与 Rails5 的主要区别。