Reputation: 8597
I have an image in my app/assets/images
folder and I'm in my view page trying to display an image.
<%= image_tag "NoAvatar.png" %>
When I load my page in localhost my image only shows /assets/
in its src path
<img alt="Assets" src="/assets/">
I'm not understanding why this is the issue? Am I doing something wrong? I thought this was how its supposed to link to an image in your pipeline?
Thanks!
Upvotes: 4
Views: 34321
Reputation: 101
If your image is in assets, use:
<%= image_tag("entretien.jpg", width: 200) %>
Upvotes: 9
Reputation: 6574
rails 3.1 n later have a new feature called 'asset pipeline', u can read it at http://guides.rubyonrails.org/asset_pipeline.html
u can access the image in the view as
= image_tag "/assets/large/icon.png"
the image 'icon.png' resides in 'large' under 'images' in 'assets'
to see how to refer the same image in css, see Rails 3.1 and Image Assets
Upvotes: 5