Forum: Ruby on Rails Images directory

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ruud P. (Guest)
on 2006-02-21 18:59
I have a template. In this template i refer to images by using <img
src="images/image.gif">. 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!
Randy S. (Guest)
on 2006-02-21 19:02
(Received via mailing list)
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
Bill W. (Guest)
on 2006-02-21 19:41
(Received via mailing list)
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
unknown (Guest)
on 2006-02-21 20:46
(Received via mailing list)
> I have a template. In this template i refer to images by using <img
> src="images/image.gif">. 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.
This topic is locked and can not be replied to.