0

我的 css 文件在开发中运行良好。

我的生产应用程序因 500 错误而失败。生产日志文件显示正在编译的 css 文件

Compiled screen/fluid/nav.css  (0ms)  (pid 16607)

那么这个错误:

Started GET "/login" for 118.211.236.235 at 2013-01-06 01:29:10 +0000
Processing by SessionsController#new as HTML
  Rendered sessions/new.html.erb within layouts/application (9.5ms)
Completed 500 Internal Server Error in 112ms

ActionView::Template::Error (avetmiss.css isn't precompiled):

该文件未在 application.css 中列出,但似乎无论如何都已编译。这是我的 application.css 文件:

/*
*= require_self
*= require_tree ./screen
*/

另一个问题是我的 application.html 文件中有打印 css,如下所示:

<%= stylesheet_link_tag 'application-print', :media => 'print' -%>

这个文件根本没有被预编译。我是否需要将它放在 production.rb 中的预编译指令中,如下所示?该指令应该放在 production.rb 还是 application.rb 中?

config.assets.precompile += %w( application-print.css )

我是否需要在上面的预编译语句中添加不是控制器资产的每个 css 和 js 文件?

4

1 回答 1

0

看起来这些文件未包含在部署的预编译步骤中。

假设 application-print.css 和 avetmiss.css 在 app/assets/stylesheets 中,请直接在 application.css 中使用它们

/*
*= require self
*= require tree ./screen
*= require avetmiss
*/

或者,如果你想在你的 app/assets/stylesheets 文件夹下包含所有 css 文件,那么在你的 application.css 中,只需:

/*
*= require self
*= require tree .
*/

Rails 资产指南对我很有帮助。

***编辑

对于您的打印 css - 我认为您确实需要一个预编译指令,因此它不会包含在 application.css

config.assets.precompile += %w( application-print.css )
于 2013-01-06T05:04:28.710 回答