Most of my assets suddenly return 404 after a push to heroku Most of my assets suddenly return 404 after a push to heroku heroku heroku

Most of my assets suddenly return 404 after a push to heroku


put line in config/environments/production.rb

config.assets.compile = true

it worked as it will compile the assets on runtime, just like in development environment, but its makes application slow, the best way is to either compile the assets locally in production environment with rake task(RAILS_ENV=production bundle exec rake assets:precompile) and commit your generated assets in public/assets and then do deployment. or, heroku run rake assets:precompile


I had this problem today with rails 4 on heroku. The article provided by @Jeff is a little bit old but, the gem repository has a good readme.Summarizing, you will need to add two gems to your Gemfile:

  1. gem 'rails_serve_static_assets' (it will solve the static assets problem) and
  2. gem 'rails_stdout_logging' (which the previous one depends on).


Heroku released a gem to handle the assets without needing to turn off compilation or to manually compile.

https://devcenter.heroku.com/articles/ruby-support#static-assets

Just add this to your Gemfile and redeploy.

gem 'rails_serve_static_assets', group: [:production]