【问题标题】:Why heroku clean assets after precomipling them?为什么在预编译它们后 heroku 清理资产?
【发布时间】:2017-05-10 05:45:21
【问题描述】:

我是Rails的新手。当我将应用程序部署到heroku时,终端显示了这样的信息:

remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        I, [2017-05-10T05:03:15.348460 #1268]  INFO -- : Writing     /tmp/build_6d070dbb68ed231a9980e7d6aee4630f/public/assets/fore- 1ea7b4ae84fb4d285d3da11143e3367c41cf15e8e44b9dba475b4b572fc7ae74.png

remote:        I, [2017-05-10T05:03:15.370482 #1268]  INFO -- : Writing /tmp/build_6d070dbb68ed231a9980e7d6aee4630f/public/assets/subdirectory/image-B-f3b8e56853071297fbe1da778049948f40f87756705420a97a157e9cf8a477be.jpg
...

remote:        Asset precompilation completed (12.71s)
remote:        Cleaning assets
remote:        Running: rake assets:clean

我们看到 app/assets/ 已经被预编译,包括图像和子目录。但是当我在heroku上打开网站时,app/assets/下的所有图片都失败了。

为了解决这个问题,我运行了RAILS_ENV=production rake assets:precompile,签入 git,再次推送。然后图像显示正确。

我的问题是:

为什么在资产预编译完成后rails clean assets(见信息末尾)。我没有更改任何默认配置。这只发生在heroku中吗?

在部署之前我必须在本地运行预编译吗?每次?

【问题讨论】:

    标签: ruby-on-rails heroku asset-pipeline


    【解决方案1】:

    config/production.rb

    config.assets.compile = true
    

    运行以下命令:

    RAILS_ENV=production rake assets:precompile
    

    然后将所有文件和清单文件推送到heroku。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-15
      • 2012-06-26
      • 1970-01-01
      • 2015-08-28
      • 1970-01-01
      • 1970-01-01
      • 2015-11-05
      • 1970-01-01
      相关资源
      最近更新 更多