Images directory

I have a template. In this template i refer to images by using . I putted the images in the public/images
folder. This works only for the base url, e.g.
http://localhost:3000/category. When i make a new category like
http://localhost:3000/category/new, the images arent displayed. When i
go to the source of the page, and look to the image url it says
/images/category/image.gif. Off course, it should be just
images/image.gif. Somehow it adds category/ to the image src url. How to
prevent Rails from doing this?
Thanks in advance!

Try making the url “/images/image.gif” (with the leading forward
slash) I think that will work, not 100% certain though.

Randy

On 2/21/06, Ruud P. [email protected] wrote:


Posted via http://www.ruby-forum.com/.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Randy S.
[email protected]
267.334.6833

I had a similar problem recently and Randy is 100% correct. The forward
slash will do what you’re looking for.
----- Original Message -----
From: “Randy S.” [email protected]
To: [email protected]
Sent: Tuesday, February 21, 2006 11:01 AM
Subject: Re: [Rails] Images directory

Try making the url “/images/image.gif” (with the leading forward
slash) I think that will work, not 100% certain though.

Randy

On 2/21/06, Ruud P. [email protected] wrote:


Posted via http://www.ruby-forum.com/.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Randy S.
[email protected]
267.334.6833


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

I have a template. In this template i refer to images by using . I putted the images in the public/images
folder. This works only for the base url

Instead of qualifying the path by prepending ‘/’, might I also suggest
using the image_tag helper:

<%= image_tag("close.gif") %>

That should continue to work even if you deploy your app to a server
that adds an extra path layer.