# Accessing images in the /public directory

**URL:** <https://www.ruby-forum.com/t/accessing-images-in-the-public-directory/177420>\
**Category:** Rails\
**Created:** [October 16, 2009, 8:52pm UTC](https://www.ruby-forum.com/t/accessing-images-in-the-public-directory/177420 "2009-10-16T20:52:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![spacechurro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d2c977/32.png) [@spacechurro](https://www.ruby-forum.com/u/spacechurro)\
**Post date:** [October 16, 2009, 8:52pm UTC](https://www.ruby-forum.com/t/accessing-images-in-the-public-directory/177420/1 "2009-10-16T20:52:42Z")

</div>

i am taking a style that someone else put together, and have a simple  
question…

the page is currently buried in the site, along with its images… i  
moved the images to /public/images

the only problem i have is…

how do i access those files in this case…

how do i encode the style attribute to access the images directory in  
the public directory?

thanks!

---

<div class="post-metadata">

**Author:** ![spacechurro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d2c977/32.png) [@spacechurro](https://www.ruby-forum.com/u/spacechurro)\
**Post date:** [October 16, 2009, 9:02pm UTC](https://www.ruby-forum.com/t/accessing-images-in-the-public-directory/177420/2 "2009-10-16T21:02:51Z")

</div>

On Oct 16, 2009, at 2:52 PM, Sergio R. wrote:

> 

background:url(‘/images/header\_bg.gif’);  
Note the initial / to make the path from your document root absolute.

> how do i encode the style attribute to access the images directory in  
> the public directory?
> 
> ## thanks!
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![spacechurro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d2c977/32.png) [@spacechurro](https://www.ruby-forum.com/u/spacechurro)\
**Post date:** [October 16, 2009, 9:09pm UTC](https://www.ruby-forum.com/t/accessing-images-in-the-public-directory/177420/3 "2009-10-16T21:09:14Z")

</div>

Rob B. wrote:

> On Oct 16, 2009, at 2:52 PM, Sergio R. wrote:
> 
> > 
> 
> background:url(‘/images/header\_bg.gif’);  
> Note the initial / to make the path from your document root absolute.

Yup. Also, never use the style attribute. Use a separate CSS file  
instead.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![spacechurro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d2c977/32.png) [@spacechurro](https://www.ruby-forum.com/u/spacechurro)\
**Post date:** [October 16, 2009, 9:20pm UTC](https://www.ruby-forum.com/t/accessing-images-in-the-public-directory/177420/4 "2009-10-16T21:20:11Z")

</div>

got it! thanks for the help, guys…

yes, this file is FULL of problems…

i just need to get transferred over before i start fixing things…

---

<div class="post-metadata">

**Author:** ![spacechurro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d2c977/32.png) [@spacechurro](https://www.ruby-forum.com/u/spacechurro)\
**Post date:** [October 16, 2009, 9:22pm UTC](https://www.ruby-forum.com/t/accessing-images-in-the-public-directory/177420/5 "2009-10-16T21:22:05Z")

</div>

Sergio R. wrote:

> got it! thanks for the help, guys…
> 
> yes, this file is FULL of problems…
> 
> i just need to get transferred over before i start fixing things…

Ouch! I’ve done that myself a few times. Good luck.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![spacechurro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d2c977/32.png) [@spacechurro](https://www.ruby-forum.com/u/spacechurro)\
**Post date:** [October 16, 2009, 9:30pm UTC](https://www.ruby-forum.com/t/accessing-images-in-the-public-directory/177420/6 "2009-10-16T21:30:33Z")

</div>

i got called in to put the guts into a design done by a college kid who  
‘knows computers’…
