# Link to public folder for attachments

**URL:** <https://www.ruby-forum.com/t/link-to-public-folder-for-attachments/161670>\
**Category:** Rails\
**Created:** [February 28, 2009, 8:06pm UTC](https://www.ruby-forum.com/t/link-to-public-folder-for-attachments/161670 "2009-02-28T20:06:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eyal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/76d3ee/32.png) [@eyal](https://www.ruby-forum.com/u/eyal)\
**Post date:** [February 28, 2009, 8:06pm UTC](https://www.ruby-forum.com/t/link-to-public-folder-for-attachments/161670/1 "2009-02-28T20:06:21Z")

</div>

Hello.

In the directory that holds my site [example.com](http://example.com), I have a symlink from  
[example.com/html/backend](http://example.com/html/backend) to the public folder in my rails application.  
That public folder holds a folder called uploads which contains  
attachments that are sent there by the attachment\_fu plugin.

However, when I link to one of these files:

\<%= link\_to “my\_file\_name”, “/uploads/0000/0009/my\_file.pdf” %\>

My browser sends me to [example.com/uploads/0000/0009/my\_file.pdf](http://example.com/uploads/0000/0009/my_file.pdf),  
instead of [example.com/backend/uploads/0000/0009/my\_file.pdf](http://example.com/backend/uploads/0000/0009/my_file.pdf).

That said, my javascript\_include\_tag and my stylesheet\_link\_tag work  
correctly and send me to the right subdirectories of my public folder:  
[example.com/backend/javascripts/](http://example.com/backend/javascripts/) and [example.com/backend/stylesheets/](http://example.com/backend/stylesheets/).

So how do these tag\_helpers know where my javascript and stylesheet  
files are, and why doesn’t rails know that my public folder is at  
[example.com/backend/](http://example.com/backend/) ?

Any help would be very appreciated.

Thanks,  
Eyal

---

<div class="post-metadata">

**Author:** ![eyal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/76d3ee/32.png) [@eyal](https://www.ruby-forum.com/u/eyal)\
**Post date:** [February 28, 2009, 8:13pm UTC](https://www.ruby-forum.com/t/link-to-public-folder-for-attachments/161670/2 "2009-02-28T20:13:24Z")

</div>

Use url\_for

Blog: [http://random8.zenunit.com/](http://random8.zenunit.com/)  
Learn rails: [http://sensei.zenunit.com/](http://sensei.zenunit.com/)

---

<div class="post-metadata">

**Author:** ![eyal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/76d3ee/32.png) [@eyal](https://www.ruby-forum.com/u/eyal)\
**Post date:** [February 28, 2009, 8:53pm UTC](https://www.ruby-forum.com/t/link-to-public-folder-for-attachments/161670/3 "2009-02-28T20:53:58Z")

</div>

You mean:

\<%= link\_to my\_filename, url\_for(“uploads/0000/0009/my\_file.pdf”) %\>

But this doesn’t change anything. How else could I use url\_for to  
access an object in the public directory?

Thanks,  
Eyal
