James
James

Reputation: 5393

rails > 3.1 development environment: how do I refernce images in app/assets/images in views?

I have an image in app/assets/images

How do I reference this in a view in my development environment?

=image_tag 'image.png'

looks for the image in public/assets. I'm guessing that the image will get copied from app/assets/images to public/assets once the app is deployed. What am I missing here? I'd appreciate any help.

Update

I'm wondering why

=image_tag 'image.png' doesn't correctly route to the image in app/assets/images with rails in development mode. The image renders as missing.

Upvotes: 1

Views: 537

Answers (2)

James
James

Reputation: 5393

This issue solved itself somehow. Sprockets now correctly routes to the image in app/assets/images

Upvotes: 1

Richard Hulse
Richard Hulse

Reputation: 10493

Yes, you are correct.

In development mode the requests to public/assets are handled by Sprockets and mapped to the correct file.

In production mode all the assets are precompiled. There is a rake task for this that needs to be included in your deployment process. This task fingerprints the assets and puts them into the public/assets folder.

Rails keeps a copy of the mappings between files referenced by helpers and what the actual name (with fingerprint) is to allow the fingerprinted name to be used in production automatically.

Upvotes: 1

Related Questions