How do I completely remove all references to application.js and application.css in a Rails app?
Tags: javascript,html,css,ruby-on-rails,ruby-on-rails-4
Problem :
I'm working in Rails 4.2.4 to deploy a very simple 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. 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!" controller generated from the Getting Started Guide.
How can I permanently disable references to these non-existent, unrequired files?
Solution :
Modify your ./app/views/layouts/application.html.erb
to only have the following content:
<%= yield %>
In other words, remove the <html>
, <head>
, and <body>
tags. There are several other ways to achieve your objective, but this might be the easiest.