# Accessing file in public directory

**URL:** <https://www.ruby-forum.com/t/accessing-file-in-public-directory/95146>\
**Category:** Rails\
**Created:** [May 23, 2006, 5:59am UTC](https://www.ruby-forum.com/t/accessing-file-in-public-directory/95146 "2006-05-23T05:59:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lantis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/4da419/32.png) [@lantis](https://www.ruby-forum.com/u/lantis)\
**Post date:** [May 23, 2006, 5:59am UTC](https://www.ruby-forum.com/t/accessing-file-in-public-directory/95146/1 "2006-05-23T05:59:41Z")

</div>

How do i access a file in the public directory of rails application? I  
have several html files in there and i want to link them from the rhtml  
file. Basically to display a popup. Here is the code in foo.rhtml:  
Learn  
more  
It doesn’t work. Any idea why?

Thanks,

Lantis.

---

<div class="post-metadata">

**Author:** ![lantis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/4da419/32.png) [@lantis](https://www.ruby-forum.com/u/lantis)\
**Post date:** [May 23, 2006, 11:11am UTC](https://www.ruby-forum.com/t/accessing-file-in-public-directory/95146/2 "2006-05-23T11:11:39Z")

</div>

Lantis S. wrote:

> How do i access a file in the public directory of rails application? I  
> have several html files in there and i want to link them from the rhtml  
> file. Basically to display a popup. Here is the code in foo.rhtml:  
> Learn  
> more  
> It doesn’t work. Any idea why?  
> It should do. Does a non-javascript [link](https://www.ruby-forum.com/summary.html)  
> work?

---

<div class="post-metadata">

**Author:** ![lantis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/4da419/32.png) [@lantis](https://www.ruby-forum.com/u/lantis)\
**Post date:** [May 23, 2006, 2:07pm UTC](https://www.ruby-forum.com/t/accessing-file-in-public-directory/95146/3 "2006-05-23T14:07:26Z")

</div>

Alex Y. wrote:

> Lantis S. wrote:
> 
> > How do i access a file in the public directory of rails application? I  
> > have several html files in there and i want to link them from the rhtml  
> > file. Basically to display a popup. Here is the code in foo.rhtml:  
> > Learn  
> > more  
> > It doesn’t work. Any idea why?  
> > It should do. Does a non-javascript [link](https://www.ruby-forum.com/summary.html)  
> > work?

It does work in my local machine. It doesn’t work though when i put it  
on a web server. A normal link [ doesnt work  
either when i put it on the web server.](https://www.ruby-forum.com/summary.html)

---

<div class="post-metadata">

**Author:** ![lantis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/4da419/32.png) [@lantis](https://www.ruby-forum.com/u/lantis)\
**Post date:** [May 23, 2006, 2:36pm UTC](https://www.ruby-forum.com/t/accessing-file-in-public-directory/95146/4 "2006-05-23T14:36:58Z")

</div>

Lantis S. wrote:

> > It should do. Does a non-javascript [link](https://www.ruby-forum.com/summary.html)  
> > work?
> 
> It does work in my local machine. It doesn’t work though when i put it  
> on a web server. A normal link [ doesnt work  
> either when i put it on the web server.](https://www.ruby-forum.com/summary.html)
> 
> [](https://www.ruby-forum.com/summary.html)

[ 

Do the stylesheets work from the dynamic pages? If so, what do the  
stylesheet tags in the generated source look like?

](https://www.ruby-forum.com/summary.html)

---

<div class="post-metadata">

**Author:** ![lantis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/4da419/32.png) [@lantis](https://www.ruby-forum.com/u/lantis)\
**Post date:** [May 23, 2006, 2:49pm UTC](https://www.ruby-forum.com/t/accessing-file-in-public-directory/95146/5 "2006-05-23T14:49:44Z")

</div>

> Do the stylesheets work from the dynamic pages? If so, what do the  
> stylesheet tags in the generated source look like?

The stylesheets work. This is the generated tag:

---

<div class="post-metadata">

**Author:** ![lantis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/4da419/32.png) [@lantis](https://www.ruby-forum.com/u/lantis)\
**Post date:** [May 23, 2006, 3:30pm UTC](https://www.ruby-forum.com/t/accessing-file-in-public-directory/95146/6 "2006-05-23T15:30:21Z")

</div>

> In that case, it looks like you’ll need to use:
> 
> [link](https://www.ruby-forum.com/project/demo/myapp/summary.html)
> 
> Can’t think off the top of my head why you might need the extra routing  
> information, though.

Prefixing ‘/project/demo/myapp/’ for each link does the trick. Like you,  
i still dont get why the extra routing is necessary. Is it because a  
symbolic link to hook up the application?

THanks,

Lantis.

---

<div class="post-metadata">

**Author:** ![lantis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/4da419/32.png) [@lantis](https://www.ruby-forum.com/u/lantis)\
**Post date:** [May 23, 2006, 2:59pm UTC](https://www.ruby-forum.com/t/accessing-file-in-public-directory/95146/7 "2006-05-23T14:59:09Z")

</div>

Lantis S. wrote:

> > Do the stylesheets work from the dynamic pages? If so, what do the  
> > stylesheet tags in the generated source look like?
> 
> The stylesheets work. This is the generated tag:

In that case, it looks like you’ll need to use:

[link](https://www.ruby-forum.com/project/demo/myapp/summary.html)

Can’t think off the top of my head why you might need the extra routing  
information, though.
