我是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,再次推送。然后图像显示正确的方式。
我的问题是:
为什么在资产预编译完成后清理资产(请参阅信息末尾)。我没有更改任何默认配置。这只发生在heroku吗?
我必须在部署之前在本地运行预编译吗?每一次?
答案 0 :(得分:0)
config.assets.compile = true
运行以下命令:
RAILS_ENV=production rake assets:precompile
然后推送所有文件&清单文件到heroku。