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.
55576cc04365dc73ec31701367a78631?d=identicon&s=25 Ruud Poutsma (ruudjah)
on 2006-02-21 17: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!
0babf8dc63e63a6684706b1ef2e1b691?d=identicon&s=25 Randy Schmidt (Guest)
on 2006-02-21 18: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 Poutsma <ruudjah@gmail.com> wrote:
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


--
Randy Schmidt
x@altorg.com
267.334.6833
2b891e820c238ded365d035771603f21?d=identicon&s=25 Bill Walton (Guest)
on 2006-02-21 18: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 Schmidt" <x@altorg.com>
To: <rails@lists.rubyonrails.org>
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 Poutsma <ruudjah@gmail.com> wrote:
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


--
Randy Schmidt
x@altorg.com
267.334.6833
_______________________________________________
Rails mailing list
Rails@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails
E0c987f680cd640c14912ebfbf0f0f07?d=identicon&s=25 unknown (Guest)
on 2006-02-21 19: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.