首先,我删除了gem 'turbolinks'
并删除了application.js
文件中需要Turbolinks的代码。所以,我在本地机器上成功禁用了Turbolinks。然后,我将我的更改推送到Heroku,但Turbolinks仍在生产中。
如何在Heroku中禁用Turbolink?
当我运行此代码时:
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。
答案 0 :(得分:1)
在文件"data-turbolinks-track" => false
app/views/layouts/application.html.erb
答案 1 :(得分:0)
基本上直接来自这里。它适用于Rails 4,但我相信步骤是相同的。
1)移除宝石' turbolinks'来自Gemfile的行。
2)从你的app / assets / javascripts / application.js中删除// = require turbolink。
3)删除两个"数据 - turbolinks-track" =>来自app / views / layouts / application.html.erb的真正哈希键/值对。