# Paths to images

**URL:** <https://discuss.rubyonrails.org/t/paths-to-images/14079>\
**Category:** rubyonrails-talk\
**Created:** [June 7, 2007, 4:32am UTC](https://discuss.rubyonrails.org/t/paths-to-images/14079 "2007-06-07T04:32:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Serengeti](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@Serengeti](https://discuss.rubyonrails.org/u/Serengeti)\
**Post date:** [June 7, 2007, 4:32am UTC](https://discuss.rubyonrails.org/t/paths-to-images/14079/1 "2007-06-07T04:32:42Z")

</div>

I am having trouble figuring out the "right" way to specify the path to an image when it is an attribute of something other than an image tag.

For example, I see that image\_tag("myimage.png") automatically knows to look in the public/images directory.

How do I accomplish the same thing for other tags? For example, my layout has:

\<td background="menu\_bg.gif" width="1"\>

Also, in my css file:

tr#logobar { background-image:url("logo\_bg.gif") }

In these cases it seems that specifying the image name is not enough.

First, I tried a relative path ("images/logo\_bg.gif") but this failed.

A full path worked ("/images/logo\_bg.gif") worked, but this causes problems for deployment.

My server has the application root in a subdirectory. In other words, my application is in:

[http://my.server.com/myapp](http://my.server.com/myapp)

All of the places where I had "/images/logo\_bg.gif" fail on the server. I have to manually change them to "/myapp/logo\_bg.gif" for them to work.

It doesn't seem like manually updating those links every time I want to deploy a new version is the right way to do this.

What am I missing here?

---

<div class="post-metadata">

**Author:** ![Serengeti](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@Serengeti](https://discuss.rubyonrails.org/u/Serengeti)\
**Post date:** [June 7, 2007, 1:44pm UTC](https://discuss.rubyonrails.org/t/paths-to-images/14079/2 "2007-06-07T13:44:02Z")

</div>

Thanks for the advice. I did as you suggested and everything appears to work fine.

FYI to any other newbies out there like me -- be sure to budget as much time for deploying from your development machine to your production machine as you spent writing your application (more, if your application is pretty simple).

I suspect that this is a one-time problem. Once I get my first app up- and-running I suspect deploying additional apps will be easy.
