简体   繁体   English

ActionView :: Template :: Error(kids.css未预编译):

[英]ActionView::Template::Error (kids.css isn't precompiled):

I'm getting this vierd error. 我收到这个严重错误。 I have added kids.css.less to my application.css. 我已经将kids.css.less添加到我的application.css中。 I can avoid this error if i add to config.assets.precompile in application(and/or environment file) array, but this is not solution that i would like to use 如果我在application(and/or environment file)数组中添加到config.assets.precompile ,则可以避免此错误,但这不是我要使用的解决方案

here is my app.css.less: 这是我的app.css.less:

/*
 *= require_self
 *= require kids.css.less
 */


 @import "theme_venera.less";

.white-card {
  .kid-word {
    h5 { font-size: @fontSizeSmall;}
  }
}

Which result me in kids.css isnt precompiled. 这导致我在kids.css中未进行预编译。

What am i missing? 我想念什么?

UPD: This error happens when i only deploy on my production server. UPD:仅在生产服务器上部署时,会发生此错误。 In my dev env i have "live" assets. 在我的开发环境中,我拥有“实时”资产。 I'm using capistrano to deploy, and my script containts assets:precompile 我正在使用capistrano进行部署,并且我的脚本包含asset:precompile

在生产模式下运行rake assets:precompile以编译和压缩样式表,然后运行该应用程序。

In development you should be assets debugging (disable the pipeline), to avoid sprockets to concatenate and minify your assets: 在开发中,您应该进行资产调试(禁用管道),以避免链轮连接并最小化您的资产:

config.assets.debug = true

If you don't, Rails expects your assets to be compiled: 如果您不这样做,Rails希望对您的资产进行编译:

rake assets:precompile

And if you don't precompile them, it will try to compile them on request if you enable it: 而且,如果您不对其进行预编译,则如果启用它,它将尝试根据要求对其进行编译:

config.assets.compile = true

Otherwise, if you don't disable the pipeline, don't compile them yourself, and don't allow Rails to do it, it will give you the error you're getting. 否则,如果您不禁用管道,请不要自己编译它们,也不要让Rails这样做,这会给您得到的错误。 In production, the usual practice is to precompile them. 在生产中,通常的做法是对其进行预编译。 Live compilation can add a significant overhead, so you shouldn't rely on it. 实时编译会增加大量开销,因此您不应该依赖它。 However, it's ok if you leave it enabled after precompiling: Rails will use your compilation first, and if it doesn't find the asset it's looking for there will compile it as an "emergency procedure" to avoid throwing an error. 但是,如果在预编译后保持启用状态也是可以的:Rails将首先使用编译,并且如果找不到所需的资产,则会将其编译为“紧急过程”以避免抛出错误。

You have all the information here: 您在这里拥有所有信息:

http://guides.rubyonrails.org/asset_pipeline.html http://guides.rubyonrails.org/asset_pipeline.html

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

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