Images directory


#1

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!


#2

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. removed_email_address@domain.invalid wrote:


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


Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails


Randy S.
removed_email_address@domain.invalid
267.334.6833


#3

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.” removed_email_address@domain.invalid
To: removed_email_address@domain.invalid
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. removed_email_address@domain.invalid wrote:


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


Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails


Randy S.
removed_email_address@domain.invalid
267.334.6833


Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails


#4

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.