我正在将Heroku Cedar堆栈用于我的Rails应用程序,并且我希望它可以在Slug编译过程中预先编译资产,因为我不想打扰Git中的预编译内容。

现在,一切都应该可以,就像日志所说的那样:

Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       /usr/local/bin/ruby /tmp/build_8bg62ph22vwj/vendor/bundle/ruby/1.9.1/bin/rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets

但是当我尝试访问该网站时 heroku logs 我得到:

2011-11-30T08:23:52+00:00 app[web.1]: ActionView::Template::Error (blueprint/screen.css isn't precompiled):
2011-11-30T08:23:52+00:00 app[web.1]:     22:   <%= javascript_include_tag 'http://html5shiv.googlecode.com/svn/trunk/html5.js' %>
2011-11-30T08:23:52+00:00 app[web.1]:     23:   <![endif]-->
2011-11-30T08:23:52+00:00 app[web.1]:     24:   <%= javascript_include_tag  'application' %>
2011-11-30T08:23:52+00:00 app[web.1]:     25:   <%= stylesheet_link_tag     'blueprint/screen', :media => 'screen' %>
…

您是否知道问题可能在哪里?

有帮助吗?

解决方案

您是否尝试过本地部署该应用程序?如果是这样,您将获得相同的结果。

使用资产管道时,它默认为通过application.css服务所有CSS。

您是否可以将样式表标签更改为:

<%= stylesheet_link_tag 'application' %>

如果在开发中正确显示,那么它也应在生产中起作用。

另外,如果您确实需要直接包含该文件,则需要修改 config/environments/production.rb 添加:

config.assets.precompile += %w( blueprint/screen.css )

其他提示

多米尼克·汤森(Dominic Townsend) 给出了绝对正确的问题来源。至于解决方案 这里 在堆栈溢出的其他问题上的答案中,是非常不错的选择。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top