我在 Rails 应用程序中使用 Heroku Cedar 堆栈,我希望它在 slug 编译期间预编译资源,因为我不想为 git 中的预编译内容烦恼。
现在看来一切都应该没问题,因为在 slug 编译期间日志显示:
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 日志
中的站点时,我得到:
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 )
关于ruby-on-rails-3 - Heroku 预编译 Assets 没有结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8323271/