开发者

rails 3.1.0: images with fingerprint not loaded in production

开发者 https://www.devze.com 2023-04-13 08:54 出处:网络
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 finge

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/environ开发者_开发知识库ments/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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消