[Heroku] Rails 3.2 アプリで rake assets:precompile エラーの解決方法

Heroku にて Rails 3.2 アプリを git push すると rake assets:precompile でエラーが出たときの解決方法をご紹介します。

Heroku

rake assets:precompile エラーメッセージ

-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       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?
       Tasks: TOP => environment
       (See full trace by running task with --trace)
       Precompiling assets failed, enabling runtime asset compilation
       Injecting rails31_enable_runtime_asset_compilation
       Please see this article for troubleshooting help:
       http://devcenter.heroku.com/articles/rails31_heroku_cedar#troubleshooting

rake assets:precompile エラーの解決方法

解決方法は、下記の設定を application.rb に追加してやるだけで OK です。

config/application.rb

# For Heroku
config.assets.initialize_on_precompile = false

以上、Heroku + Rails 3.2 で rake assets:precompile エラーを解決したい、現場からお送りしました。

参考情報