CSS or Javascript Assets not Working on Heroku Production

I had a weird issue where on my local environment, everything worked fine, but on production when pushed to heroku, my javascript and css files weren’t getting loaded.

Now I don’t fully understand the asset pipeline and if/how it was involved in this error, but here’s what worked for me.

Simply manually precompile assets prior to pushing to heroku:

bundle exec rake assets:precompile

You will notice that this create a bunch of files.  Then you need to commit to git, and push to heroku again.

git add .
git commit -am "message"
git push origin master
git push heroku master

If you know a good explanation of why this is necessary, please let me know!

Credit here.

Advertisements

3 Responses to CSS or Javascript Assets not Working on Heroku Production

  1. Curt says:

    i’m here just to say……..thank you very much !!!!!!!!!, I was going crazy here because I did`t understand why it was all working fine at ” localhost” , but after deploy to heroku javascript stops. I still can’t understand why, it’s true , but at least now it’s all ok !!!

  2. JC says:

    Thanks that worked perfect for me !

  3. contatoyubb says:

    I’m using the wordpress files and when I try the precompile it returns to me: Could not locate Gemfile or .bundle/directory…

    that may be because I’m not running a rails app but simply installed the wordpress plugin.

    Does anyone know how to fix it? Many thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: