# Background image location

**URL:** <https://www.ruby-forum.com/t/background-image-location/73496>\
**Category:** Rails\
**Created:** [October 24, 2006, 10:50pm UTC](https://www.ruby-forum.com/t/background-image-location/73496 "2006-10-24T22:50:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [October 24, 2006, 10:50pm UTC](https://www.ruby-forum.com/t/background-image-location/73496/1 "2006-10-24T22:50:27Z")

</div>

I’m having problems getting a background image to load in rails.

In my public/images directory, I have a file rightimage.jpg.

In my stylesheet, I have an entry as follows:  
td.rightcolumn {  
background-image: url(/images/rightimage.jpg);  
background-position: top left;  
background-repeat: no-repeat;  
}

In my layout, I have

  
&nbsp;  

The dummy space in the column will be replaced by text, so I can’t  
simply use an \<%= image-tag … %\> entry - it’s going to have text over  
it. On the background-image entry, I’ve tried url(images/rightimage.jpg)  
and url(/images/rightimage.jpg). I can’t get the background image to  
load on the page. I’m assuming that it’s because it’s not being found.

How do I get a background image to load in rails?

Thanks in advance.  
—Michael

---

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [October 24, 2006, 11:02pm UTC](https://www.ruby-forum.com/t/background-image-location/73496/2 "2006-10-24T23:02:57Z")

</div>

> The dummy space in the column will be replaced by text, so I can’t  
> simply use an \<%= image-tag … %\> entry - it’s going to have text over  
> it. On the background-image entry, I’ve tried url(images/rightimage.jpg)  
> and url(/images/rightimage.jpg). I can’t get the background image to  
> load on the page. I’m assuming that it’s because it’s not being found.
> 
> How do I get a background image to load in rails?

Try:

background-image: url(…/images/rightimage.jpg);

Michael

---

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [October 24, 2006, 11:29pm UTC](https://www.ruby-forum.com/t/background-image-location/73496/3 "2006-10-24T23:29:07Z")

</div>

Michael T. wrote:

> background-image: url(…/images/rightimage.jpg);
> 
> Michael

I use this…

background-image: url("/images/watermark.jpg")

\_Kevin

---

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [October 25, 2006, 12:08am UTC](https://www.ruby-forum.com/t/background-image-location/73496/4 "2006-10-25T00:08:17Z")

</div>

Michael T. wrote:

> Try:
> 
> background-image: url(…/images/rightimage.jpg);

No good. Still doesn’t load.

—Michael

---

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [October 25, 2006, 12:09am UTC](https://www.ruby-forum.com/t/background-image-location/73496/5 "2006-10-25T00:09:09Z")

</div>

\_Kevin wrote:

> Michael T. wrote:
> 
> > background-image: url(…/images/rightimage.jpg);
> > 
> > Michael
> 
> I use this…
> 
> background-image: url("/images/watermark.jpg")

The addition of quotes looked like something I’d miss, but it still  
doesn’t load.

Thanks for trying  
—Michael

---

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [October 25, 2006, 1:27am UTC](https://www.ruby-forum.com/t/background-image-location/73496/6 "2006-10-25T01:27:26Z")

</div>

Michael S. wrote:

> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Try sticking the background-image on your body to see if it is really  
loading or not.  
There may be another reason it isn’t displaying.

\_Kevin

---

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [October 25, 2006, 4:17am UTC](https://www.ruby-forum.com/t/background-image-location/73496/7 "2006-10-25T04:17:42Z")

</div>

Hi Michael,

I haven’t followed this back to the original post so forgive me if this  
has  
already been covered.

Are you able to load other images and only having problems with the  
background images?

Best regards,  
Bill

---

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [October 25, 2006, 9:08pm UTC](https://www.ruby-forum.com/t/background-image-location/73496/8 "2006-10-25T21:08:31Z")

</div>

Try addeding explicit {height: xxx; width: xxxx} of the image to your  
style  
…

---

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [October 25, 2006, 8:08pm UTC](https://www.ruby-forum.com/t/background-image-location/73496/9 "2006-10-25T20:08:24Z")

</div>

rightImage.jpg perhaps? Case issues on \*nix systems.

Vish
