如何在 Heroku 上禁用 Turbolinks?

How to disable Turbolinks on Heroku?

首先,我删除了gem 'turbolinks'并删除了application.js文件中需要Turbolinks的代码。所以,我成功地在我的本地机器上禁用了 Turbolinks。然后,我将更改推送到 Heroku,但 Turbolinks 仍在生产中。

如何在 Heroku 中禁用 Turbolinks?

当我运行这段代码时:

heroku run cat app/assets/javascripts/application.js

我得到以下代码:

//This is a manifest file that'll be compiled into application.js, which 
//will include all the files listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require jquery-ui/effects/effect-highlight
//= require bootstrap
//= require material
//= require materialize-sprockets
//= require custom
//= require cocoon
//= require underscore
//= require_tree .

此外,我的 Gemfile 在生产环境中看起来像这样:

source 'https://rubygems.org'

gem 'rails',                   '4.2.2'
gem 'bcrypt',                  '3.1.7'
gem 'faker',                   '1.4.2'
gem 'carrierwave',             '0.10.0'
gem 'mini_magick',             '3.8.0'
gem 'fog',                     '1.36.0'
gem 'will_paginate',           '3.0.7'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'bootstrap-sass',          '3.2.0.0'
gem 'sass-rails',              '5.0.6'
gem 'uglifier',                '2.5.3'
gem 'materialize-sass'
gem 'coffee-rails',            '4.1.0'
gem 'jquery-rails',            '4.0.3'
gem 'jbuilder',                '2.2.3'
gem 'sdoc',                    '0.4.0', group: :doc
gem 'omniauth-facebook'
gem 'figaro'
gem 'material_design_lite-sass'
gem 'material_icons'
gem "font-awesome-rails"
gem 'cocoon'
gem 'simple_form'
gem 'jquery-ui-rails'
gem 'activerecord-reset-pk-sequence'
gem 'underscore-rails'
group :development, :test do
  gem 'sqlite3',     '1.3.9'
  gem 'byebug',      '3.4.0'
  gem 'web-console', '2.0.0.beta3'
  gem 'spring',      '1.1.3'
  gem "better_errors"
  gem "binding_of_caller"
end

group :production do
  gem 'pg',             '0.17.1'
  gem 'rails_12factor', '0.0.2'
  gem 'puma',           '3.1.0'
end

我还删除了 application.html.erb 中的所有 Turbolinks 引用。

但是,Turbolinks 并没有在生产环境中被禁用。可以解决什么问题?

注意:Turbolinks 在我的开发环境中被成功禁用。

基本上直接从这里开始。 Rails 4,但我相信步骤是一样的。

1) 从 Gemfile 中删除 gem 'turbolinks' 行。

2) 从您的 app/assets/javascripts/application.js .

中删除 //= 需要 turbolinks

3) 从 app/views/layouts/application.html.erb .

中删除两个 "data-turbolinks-track" => true hash key/value 对

在文件 app/views/layouts/application.html.erb 中创建 "data-turbolinks-track" => false