【问题标题】:Heroku precompilation of assets with no resultHeroku对资产的预编译没有结果
【发布时间】:2012-01-09 12:44:50
【问题描述】:

我正在为我的 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 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' %>
…

你知道问题出在哪里吗?

【问题讨论】:

    标签: ruby-on-rails-3 heroku asset-pipeline precompile cedar


    【解决方案1】:

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

    使用资产管道时,默认通过 application.css 提供所有 CSS。

    你能把你的样式表标签改成:

    <%= stylesheet_link_tag 'application' %>
    

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

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

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

    【讨论】:

    • 你是对的。我刚刚在 webrick 上对其进行了本地测试,我认为这些东西是“在运行时编译的”,因为一切都完美无缺。
    【解决方案2】:

    Dominic Townsend 给出了绝对正确的问题根源。至于解决方案here 在其他关于堆栈溢出的问题的答案中是非常好的选择。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-12
      • 2023-03-09
      • 2015-08-28
      • 1970-01-01
      • 2012-06-26
      • 2012-11-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多