Hi, I am new to rails and developing my first application. At one point I have to display image. I am using- <%= image_tag("Smileimg2.jpeg", :height => 185, :width => 313) %> BUT image is not showing in the browser. My image is in public/images folder, as well as in app/assets/images folder also. Please help!!
I would use the inspector in the browser and see where the src is pointing to. That will give you a clue as to the path it is taking. Based on your email It **should be pointing to: src="/images/Smileimg2.jpeg". Also, checkout your image file name and make sure your casing is correct. Personally i would go with all lowercase letters and maybe dashes or underscores. e.g. smile_img_2.jpg
Matt
The generated HTML is -
<img alt="Smileimg2" height="185" src="/assets/Smileimg2.jpeg" width="313">
So I placed the image there too, but to no use. Do I have to tweak in config>environment folder???
Theoretically the picture should show up if you put it into /app/assets/images/
But there might probably a problem with your version of sprockets, some rails versions are using very old sprockets versions, so please tell us which rails and sprockets version you are locked to (Gemfile.lock) if my hint above doesn’t work.
My Rails version is 3.2.12!!
I have this image placed wherever I think it should be-
app/assets/images, in app/assets, in public/assets, in public/images.
BUT none works.
I checked sprockets in gemfile.lock. There are two mentions of
sprockets-
first this(last line)-
actionpack (3.2.12)
activemodel (= 3.2.12)
activesupport (= 3.2.12)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.5)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
and second this-
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
Hey, I changed my pic from .jpeg to .png and its working. BUT I want .jpeg files to work. Now whats the glitch here? Its strange!
Ohhh Good God!! Problem sorted!! Thnks Norbert and buyzlots for giving your precious time.
Ohhh Good God!! Problem sorted!! Thnks Norbert and buyzlots for giving your precious time.
And the fix was?
Colin
@Colin - I was writing image_1.jpeg, but when I wrote image_1.jpg it worked. It worked on .png too.