Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Images broken after uploading Rails app to heroku

Shows fine locally. But when I upload to Heroku, I get the following:

enter image description here

<%= image_tag('logo-red.png') %>

and it's located in assets/images/

I'm not using Turbolinks. Do I need to run a command on Heroku to solve this or is there some config setting I'm missing?

edit 1: tried running heroku run rake assets:precompile RAILS_ENV=production

edit 2: response from heroku staff:

It looks like your app is properly compiling that image: ~/public/assets $ pwd /app/public/assets ~/public/assets $ ls | grep logo-red logo-red-a07050d882e1dba431cef2130d39f929c611eaf8b0ec3c50db0742ddccb14d93.png

edit 3: See attached screenshot enter image description here

like image 871
Jackson Cunningham Avatar asked Oct 02 '15 19:10

Jackson Cunningham


2 Answers

Try running on your local computer:

rake assets:precompile
rake assets:clean

Then commit and push to heroku.

Also check your production.rb file and make sure everything related to compiling or precompiling is true and not false ie:

config.serve_static_assets = true
config.assets.compile = true

Also, make sure rails_12factor is in your gemfile like so:

gem 'rails_12factor', group: :production
like image 154
Philip7899 Avatar answered Nov 18 '22 14:11

Philip7899


Had this problem on Heroku before - we solved it by precompiling the assets on Heroku itself:

$ heroku run rake assets:precompile RAILS_ENV=production

I know this is done when you push the repo to Heroku; it's one of those quirks which seems to be resolved if you compile the assets on their server.

You could also precompile locally as long as you make sure the RAILS_ENV is production:

$ rake assets:precompile RAILS_ENV=production

like image 31
Richard Peck Avatar answered Nov 18 '22 12:11

Richard Peck