3

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!

hellomello
  • 8,219
  • 39
  • 151
  • 297

2 Answers2

7

If your image is in assets, use:

<%= image_tag("entretien.jpg", width: 200) %>
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Albert Ngodi
  • 71
  • 1
  • 2
5

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

Community
  • 1
  • 1
Prasad Surase
  • 6,486
  • 6
  • 39
  • 58