Last Updated: February 25, 2016
·
1.69K
· rfischer20

Fixed: Initialize On Precompile Rails Assets Error for Heroku Cedar

A common error on Heroku’s Cedar Stack is during precompile for assets:

could not connect to server: Connection refused. Is the server running on host “127.0.0.1″ and accepting TCP/IP connections on port xxxx?

This issue is resolved by disabling the app initializing for compiling assets. But I came across a situation where that solution caused further issues. This was due to the js-routes gem needing info about routes from my app. This forced me to compile my assets every time I pushed changes to Heroku. It quickly becomes annoying running this task all the time and then having caching issues during development.

Heroku Labs to the rescue! There is a experimental feature that allows the app to be initialized during precompile by allowing user variables to be accessed.

It is simple as:

heroku labs:enable user-env-compile -a myapp

Replace myapp with your application name and push a new change to cause the slug to be recompiled. Now I no longer need to precompile assets and Heroku handles everything. I haven’t had any issues but they do warn to be careful when enabling this feature.

Reposted from my blog

1 Response
Add your response

This not work, now :(

over 1 year ago ·