在推送到Heroku之前,是否可以在Rails应用程序中自动预编译我的资产?我总是忘记这么做,所以如果我输入git push heroku master
,它会首先运行rake assets:precompile ; git commit add . ; git commit -a -m "Precompile."
,或者这样做。在推送到Heroku之前自动预先编译资源
有没有人取得过这样的解决方案?可能没有挂钩?虽然我怀疑这是唯一的方法。
在推送到Heroku之前,是否可以在Rails应用程序中自动预编译我的资产?我总是忘记这么做,所以如果我输入git push heroku master
,它会首先运行rake assets:precompile ; git commit add . ; git commit -a -m "Precompile."
,或者这样做。在推送到Heroku之前自动预先编译资源
有没有人取得过这样的解决方案?可能没有挂钩?虽然我怀疑这是唯一的方法。
我终于明白了这一点。我确实在Cedar堆栈上。问题是我检查了我的public
目录到Git中,当我推送到Heroku时,它意识到public
存在,并且因此假定我进行了预编译。运行git rm -r public
并将public/**
添加到我的.gitignore
,然后推送,修复问题。
你总是可以别名heroku
或在您的bash配置文件类似于rake assets:precompile ; git commit add . ; git commit -a -m "Precompile." ; git push heroku master
东西 即
#in ~/.bash_profile
alias precompile_push='rake assets:precompile ; git commit add . ; git commit -a -m "Precompile." ; git push heroku master'
这听起来像你可能不上Heroku's Cedar Stack?如果您使用的是资产管道(Rails -v> = 3.1),则雪松会提供three options来编译资产。
从docs:
如果您还没有编译本地资产,我们将尝试蛞蝓编译过程中运行
assets:precompile
任务。
在雪松堆叠上,它会在slu comp编译期间完成此操作。我建议。
我创建了一个作为守护进程运行的gem,并自动从Git仓库中提取更改,预编译资产,提交并推回。
如果这是你的部署过程的一部分,我会建议做,在你的代码的脚本。 –