简体   繁体   English

如何完全删除Rails应用程序中对application.js和application.css的所有引用?

[英]How do I completely remove all references to application.js and application.css in a Rails app?

I'm working in Rails 4.2.4 to deploy a very simple Web API. 我正在Rails 4.2.4中部署一个非常简单的Web API。 This interface does not require JavaScript or CSS, so the requests for application.js and application.css are just generating log spam and increasing response times. 该接口不需要JavaScript或CSS,因此对application.jsapplication.css的请求仅生成日志垃圾邮件,并增加了响应时间。 I have tried disabling assets and skipping sprockets , but the pages served by the app continue to reference application.js and application.css , even in my "Hello, world!" 我曾尝试禁用资产并跳过链轮 ,但该应用程序所服务的页面仍继续引用application.jsapplication.css ,即使在我的“ Hello,world!”中也是如此。 controller generated from the Getting Started Guide . 根据入门指南生成的控制器。

How can I permanently disable references to these non-existent, unrequired files? 如何永久禁用对这些不存在的不需要文件的引用?

Modify your ./app/views/layouts/application.html.erb to only have the following content: 将您的./app/views/layouts/application.html.erb修改为仅包含以下内容:

<%= yield %>

In other words, remove the <html> , <head> , and <body> tags. 换句话说,删除<html><head><body>标记。 There are several other ways to achieve your objective, but this might be the easiest. 还有其他几种方法可以实现您的目标,但这可能是最简单的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Rails 4应用程序在暂存/生产中缺少application.js和application.css - Rails 4 app is missing application.js and application.css on staging/production Rails-如何重构application.js? - Rails - How to refactor application.js? 为什么所有的注释对rails中的application.css.scss和application.js都没有影响 - Why all comments have no effect of application.css.scss and application.js in rails Application.js 未在 Rails 6 中加载 - Application.js not loading in Rails 6 `application.js`不再包括Rails 3.1应用程序的app / assets / javascripts中的所有脚本 - `application.js` no longer including all scripts in app/assets/javascripts for Rails 3.1 app Rails 3.2.3-Javascript-application.js-link_to_remove_fields - rails 3.2.3 - javascript - application.js - link_to_remove_fields rails - 如何升级我的jquery,我没有在app / assets中看到它,但它在application.js中被引用? - rails - how can I upgrade my jquery, I don't see it in app/assets but it's referenced in application.js? 如何在Rails中将脚本从视图移动到application.js - How to move script from view to application.js in rails Ruby on Rails - 如何在application.js中执行require - Ruby on Rails - how require is executed in application.js 如何从rails中的application.js访问yml文件? - how to access the yml file from application.js in rails?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM