1

My problem: All images aren't loaded correctly when I start my app in production mode. I see only a placeholder for the image. When I copy the image-url I get "assets/mylogo.png". I miss the fingerprint.

My config:

Gems:

rails 3.1.0
compass, :git => 'git://github.com/chriseppstein/compass.git'
sprockets 2.0.2

config/application.rb :

config.assets.enabled = true

config/environments/production.rb :

config.cache_classes = true
config.consider_all_requests_local       = false
config.action_controller.perform_caching = true
config.serve_static_assets = false
config.assets.compress = true

After the deploy I run

rake assets:clean
rake assets:precompile

In the public/assets folder are all images (and js, css files) with the fingerprint at the end.

In development mode everything works fine. I can't figure out why the images aren't correctly used.

Richard Hulse
  • 10,383
  • 2
  • 33
  • 37
Sebastian
  • 3,379
  • 2
  • 23
  • 39

1 Answers1

1

I see the problem. You are missing these lines in your production config:

config.assets.digest = true
config.assets.compile = false

The first turns on the addition of digests to the output from the helpers.

The second tells rails to NOT hand any requests for assets back to Sprockets, but to assume that they are precompiled (which is what you want).

In Rails 3.1.0 only digested assets are precompiled, which is why you got a placeholder. In 3.1.1 the non digest versions are also compiled, so you config would have worked, but the best practice is with digests on.

The last section of the assets pipeline guide has a list of the correct config options for default operation.

Richard Hulse
  • 10,383
  • 2
  • 33
  • 37