推入Heroku时出错(预编译资产失败。)

时间:2013-12-13 13:33:19

标签: ruby-on-rails heroku ruby-on-rails-3.2 heroku-postgres

注意:我使用的是Rails 3.2.13和Ruby“1.9.3”,以及postgres-0.15.1

我尝试按照本网站的程序将我的Ruby on Rails应用程序推送到heroku http://ruby.railstutorial.org/ruby-on-rails-tutorial-book#sec-deploying ,但是在尝试进入heroku时我遇到了错误

   Connecting to database specified by DATABASE_URL
   rake aborted!
   could not connect to server: Connection refused
   Is the server running on host "127.0.0.1" and accepting
   TCP/IP connections on port 5432?
 !     Precompiling assets failed.
 !     Push rejected, failed to compile Ruby app

To git@heroku.com:pure-hamlet-9148.git
 ! [remote rejected] master -> master (pre-receive hook declined)

所以,我用Google搜索并运行以下命令

heroku labs:disable user-env-compile
heroku labs:enable user-env-compile

仍有同样的错误,请帮我解决此问题。

3 个答案:

答案 0 :(得分:3)

与Simone的回答一起,

在部署之前,请按照此网站在本地预编译您的资产。 https://devcenter.heroku.com/articles/rails-asset-pipeline

RAILS_ENV=production bundle exec rake assets:precompile
git add public/assets -f
git commit -m "vendor compiled assets"

答案 1 :(得分:2)

查看有关Heroku and Rails asset:precompile error的文章。你应该设置

config.assets.initialize_on_precompile = false

答案 2 :(得分:0)

解决此错误的方法: 首先设置DATABASE_URL环境变量&然后再次尝试将代码再次推送到Heroku。它在Heroku方面完成所有rake编译工作,所以没有更多连接到本地机器制作rake编译@ ... / tmp / bin .....目录。