2011-11-25 77 views
9

在推送到Heroku之前,是否可以在Rails应用程序中自动预编译我的资产?我总是忘记这么做,所以如果我输入git push heroku master,它会首先运行rake assets:precompile ; git commit add . ; git commit -a -m "Precompile.",或者这样做。在推送到Heroku之前自动预先编译资源

有没有人取得过这样的解决方案?可能没有挂钩?虽然我怀疑这是唯一的方法。

回答

14

我终于明白了这一点。我确实在Cedar堆栈上。问题是我检查了我的public目录到Git中,当我推送到Heroku时,它意识到public存在,并且因此假定我进行了预编译。运行git rm -r public并将public/**添加到我的.gitignore,然后推送,修复问题。

3

你总是可以别名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' 
+1

如果这是你的部署过程的一部分,我会建议做,在你的代码的脚本。 –

8

这听起来像你可能不上Heroku's Cedar Stack?如果您使用的是资产管道(Rails -v> = 3.1),则雪松会提供three options来编译资产。

docs

如果您还没有编译本地资产,我们将尝试蛞蝓编译过程中运行 assets:precompile任务。

1

在雪松堆叠上,它会在slu comp编译期间完成此操作。我建议。

相关问题