Rails 4: How To Fix The Heroku Assets Not Found CSS Image Issue

So I uploaded my first Rails 4 project to Heroku only to find that none of my assets, including CSS and images were rendering.

While I found some solutions that fixed the CSS rendering, I had a hard time finding a solution that rendered my background image in this simple SASS code:

background: url(auth-icons.png) no-repeat 99px 99px;

According to this StackOverflow question about the same issue, heroku actually adds an identifier to all your image names to optimize cashing, so the CSS can’t find an image with that exact name.

The solution ended up being very simple. Just change the config.assets.compile option in your production.rb file to true:

# config/environments/production.rb
YOURAPPLICATION::Application.configure do
   # your config settings

   config.assets.compile = true

   # your other config settings

That should fix it!

Enjoy the article? Join over 20,000+ Swift developers and enthusiasts who get my weekly updates.