开发者

Rails 3.1 image asset timeout

I'm having intermittent issues with images on Rails 3.1.

The file in question is a simple PNG; all other images are working correctly. If I vist the asset path directly the image works as expected. Restarting the server (Webrick, in development) does not help. Clearing the browser cache does not help.

When I reload the page the image shows but the browser indicates it is still loading. After 30 seconds the request times out and the image is replaced with a broken image indicator.

Here are a few supporting images:

https://skitch.com/matt_darby/fahke/oops-google-chrome-could-not-connect-to-localhost-3000

https://skitch.com/matt_darby/fahkp/oops-google-chrome-could-not-connect-to-localhost-3000

https://skitch.com/matt_darby/fahkw/contact.html.haml-documents-cod开发者_如何学JAVAe-protectedmethod.com-app-views-pages-vim


I too had this issue and Richard Hulse's comment above to his own answer: "delete the files in tmp/cache/assets and restart' fixed it for me. Thanks Richard.


I suspect this is not working because you are running in production mode locally, or have digest turned on in your config.

In your view you should be using the asset_tag helper:

%img{ :src => asset_path('/assets/phone.png') }

This ensures that the correct path (with the fingerprint) is rendered into the view.

The code you have will work in development mode (or without digests), but will break when they are on, or in production.

If this is an upgraded app, check the Rails asset pipeline guide for the correct stuff to paste into your config files.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜