Rails:如何在 Rails 5 中禁用 turbolinks? [英] Rails: How to disable turbolinks in Rails 5?

查看:50
本文介绍了Rails:如何在 Rails 5 中禁用 turbolinks?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在处理 websockets 时,这总是令人头疼的问题,除了添加错误之外,它还会扼杀我的性能.由于 ActionCable 是我升级的全部原因,我非常想完全摆脱它.

It's a constant headache when dealing with websockets, and it kills my performance in addition to adding bugs. Since ActionCable is the whole reason I upgraded I'd very much like to get rid of it completely.

推荐答案

基本上直接来自 这里.它适用于 Rails 4,但我相信步骤是相同的​​.

Basically straight from here. It's for Rails 4, but I believe the steps are the same.

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

1) Remove the gem 'turbolinks' line from your Gemfile.

2) 从您的 app/assets/javascripts/application.js 中删除 //= require turbolinks .

2) Remove the //= require turbolinks from your app/assets/javascripts/application.js .

3) 删除两个 "data-turbolinks-track" =>true 来自您的 app/views/layouts/application.html.erb 的哈希键/值对.

3) Remove the two "data-turbolinks-track" => true hash key/value pairs from your app/views/layouts/application.html.erb .

至少从 Rails 5.0.0 开始,最后一步应该参考 "data-turbolinks-track" =>重新加载" 而不是 data-turbolinks-track" =>真的. 感谢@boddhisattva

至少从 Rails 4.2 开始,您可以生成一个没有 turbolinks 的项目.只需使用以下内容:

rails new my_app --skip-turbolinks

这篇关于Rails:如何在 Rails 5 中禁用 turbolinks?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆