Hi,
I’m new to Rails, sorry if I’m repeating the question, but I couldn’t
find a solution for my problem so far
I’m using Apache2 as the web server of my Rails application. I keep my
images in public/images and tried inserting images to the page like
“public” is your webroot… that’s where apache starts looking for stuff
to serve.
“images” is a subdirectory of “public”.
<%= image_tag “rails.png” %>
This is going to make an image tag with src=“rails.png”… which, since
you didn’t specify
a path, means apache is going to look in your webroot… or the “public”
directory.
Thanks a lot Ben, but still it doesn’t work. When I view the page source
of the browser, it correctly shows as,
but still the image is not visible on any of the browsers.
Ben M. wrote:
Umesha wrote:
Hi,
I’m new to Rails, sorry if I’m repeating the question, but I couldn’t
find a solution for my problem so far
I’m using Apache2 as the web server of my Rails application. I keep my
images in public/images and tried inserting images to the page like
“public” is your webroot… that’s where apache starts looking for stuff
to serve.
“images” is a subdirectory of “public”.
<%= image_tag “rails.png” %>
This is going to make an image tag with src=“rails.png”… which, since
you didn’t specify
a path, means apache is going to look in your webroot… or the “public”
directory.
Try to right click on the missing image, choose properties (if your
using
firefox) and see what path is beeing used.
You should be able to figure out why it is not displayed.
Well you’ve got me stumped then… you’re sure it’s in the same app
directory?
b
Yes, the image (rails.png) is placed in
‘C:\Program Files\Apache
Group\Apache2\htdocs\apache_rails\public\images’ where my application
folder is named as ‘apache_rails’.
And I’ve specified the Document root of Apache as
‘DocumentRoot “C:/Program Files/Apache
Group/Apache2/htdocs/apache_rails/public”’ in httpd.conf file
For the simplicity I have only following 2 lines in the relavent view
file.
Displaying an image
<%= image_tag "/images/rails.png" %>
But once it is viewed from a browser, only the heading is displayed with
the word ‘Rails’ under that and it’s page source is,
Displaying an image
But once I do the same thing in a application using WEBrick server with
the same view file and image placed in it’s ‘public\images’, the image
is visible. Also it’s page source is same as above.