Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku does not serve background image, localhost does?

I have a problem with my rails application (Rails 4.0.0.rc2, ruby 2.0.0p195).

The behavior is weird: My localhost shows the background picture properly, Heroku doesn't.

In the heroku logs I can see the following error:

ActionController::RoutingError (No route matches [GET] "/assets/piano.jpg"):

I have created the background image by inserting the following code in my custom.css.scss:

.full { 
  background: image-url("piano.jpg") no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

And I am triggering this with the following code, which I have on my static page:

<body class="full">
....
</body>

I already have the gem running in production:

group :production do
  gem 'pg'
  gem 'rails_12factor'
end

In production.rb I have set the following setting to true:

config.serve_static_assets = true

However, the image is not being shown. Can you help me out?

like image 462
Alex Avatar asked Oct 05 '13 17:10

Alex


1 Answers

Make sure you set these in your production.rb file

config.cache_classes = true
config.serve_static_assets = true
config.assets.compile = true
config.assets.digest = true
like image 185
Brock90 Avatar answered Oct 19 '22 05:10

Brock90