When building an application in RoR, we may need some images on the web page. In RoR application images are stored in ‘public/images/’ folder and we need to embed those images in our view pages which contains the HTML tag.
I am working on the windows with ruby 1.9.2 and rails 3.0.1.
What I have done, for putting the images in the view page I have used the following code(Let us assume that a header.gif file is in the “public/images” directory).
The above code worked fine. But some cases while loading the images, the server failed and broke down with a message http://localhost:3000/images/header.gif could not be found. And I had to start my server again and again. To fix this issue, I have used the image_tag provided by ruby. Please check the following code.
0, :class => ‘headerImg’, :size => “200×75”) %>
At the run time, this image_tag creates the following code