Relative paths for images problem

Hi all,

I have a possibly dumb question.

In my template, I reference the images folder by “…/images/foo.jpg”.
This works with all my pages that are two levels - i.e. this works for
example with “…/items/list” page.

However, when I go one level deeper, for example “…/items/show/235”
page, this doesn’t work, because images need to be referenced by
“…/…/images/foo.jpg”

Is there a quick and elegant Rails-like solution to this? Can I do
something like “~/images/foo.jpg” (it has to work both on Windows, where
I’m developing this, and Linux, where this is going to be deployed)? I
really don’t want to refer to all images by their absolute path…

Thanks!

On Mar 21, 2007, at 7:47 PM, zavulon wrote:

page, this doesn’t work, because images need to be referenced by
“…/…/images/foo.jpg”

Is there a quick and elegant Rails-like solution to this? Can I do
something like “~/images/foo.jpg” (it has to work both on Windows,
where
I’m developing this, and Linux, where this is going to be deployed)? I
really don’t want to refer to all images by their absolute path…

Thanks!

Don’t use relative paths like that. If you just always use a path
like “/images/foo.jpg” it will work no matter how nested your pages
are.

Cheers-
– Ezra Z.
– Lead Rails Evangelist
[email protected]
– Engine Y., Serious Rails Hosting
– (866) 518-YARD (9273)

Thank you, that works perfectly! I had a suspicion 'twas a stupid
question…