简体   繁体   English

Rails 4应用程序在暂存/生产中缺少application.js和application.css

[英]Rails 4 app is missing application.js and application.css on staging/production

My layout references: 我的布局参考:

  <%= stylesheet_link_tag    "application", media: "all", "data-turbolinks-track" => true %>
  <%= javascript_include_tag "application", "data-turbolinks-track" => true %>

which renders in the html page on staging and production as: 在临时页面和生产页面的html页面中显示为:

  <link data-turbolinks-track="true" href="/stylesheets/application.css" media="all" rel="stylesheet" />
  <script data-turbolinks-track="true" src="/javascripts/application.js"></script>

On development, this renders as: 在开发中,这表示为:

  <link data-turbolinks-track="true" href="/assets/application.css" media="all" rel="stylesheet" />
  <script data-turbolinks-track="true" src="/assets/application.js"></script>

which works. 哪个有效。

I have config.assets.compile set to false, but even running rake assets:precompile has no effect - the rails app is still missing /javascripts/application.js and /stylesheets/application.css on staging and production. 我已经将config.assets.compile设置为false,但是即使运行rake资产:precompile也没有效果-Rails应用程序在登台和生产时仍然缺少/javascripts/application.js和/stylesheets/application.css。

Why aren't those assets compiling to /public? 这些资产为什么不编译为/ public?

In production.rb file you will have config.serve_static_assets = false but you need to set it true because when you compile assets for production mode, i mean always it runs on server in production mode so set it to true, so that for production your assets could compile and you will have all js, css, images running. 在production.rb文件中,您将具有config.serve_static_assets = false,但是您需要将其设置为true,因为当您为生产模式编译资产时,我的意思是它总是在生产模式下在服务器上运行,因此将其设置为true,以便在生产环境中使用资产可以编译,您将运行所有js,css和图像。

config.assets.compile = true
config.serve_static_assets = true

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM