# Link\_to static html problem

**URL:** <https://www.ruby-forum.com/t/link-to-static-html-problem/79999>\
**Category:** Rails\
**Created:** [December 20, 2006, 8:03pm UTC](https://www.ruby-forum.com/t/link-to-static-html-problem/79999 "2006-12-20T20:03:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cpjolicoeur](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a183cd/32.png) [@cpjolicoeur](https://www.ruby-forum.com/u/cpjolicoeur)\
**Post date:** [December 20, 2006, 8:03pm UTC](https://www.ruby-forum.com/t/link-to-static-html-problem/79999/1 "2006-12-20T20:03:57Z")

</div>

I’m having trouble linking to a static HTML page using rails link\_to  
helper.

I have the page foo.html in my RAILS\_ROOT/public/ directory and if i try  
to access the page manually by url [www.mysite.com/foo](http://www.mysite.com/foo) it works fine.

but i’m trying to link to that file with rails link\_to and it doesnt  
work.

link\_to ‘my\_link’, “#{RAILS\_ROOT}/public/foo.html”

this gives me a Routing Error trying to load the static file.

what am I doing wrong here?

---

<div class="post-metadata">

**Author:** ![cpjolicoeur](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a183cd/32.png) [@cpjolicoeur](https://www.ruby-forum.com/u/cpjolicoeur)\
**Post date:** [December 20, 2006, 8:07pm UTC](https://www.ruby-forum.com/t/link-to-static-html-problem/79999/2 "2006-12-20T20:07:48Z")

</div>

Craig J. wrote:

> link\_to ‘my\_link’, “#{RAILS\_ROOT}/public/foo.html”

That will create something like:

[my link](https://www.ruby-forum.com/home/var/www/myapp/public/foo.html)

this is ibviously not what you want. The link\_to helper only wants the  
public path to your file, not the absolute path to the file on the disk.  
You are way over thinking this.

\<%= link\_to ‘my link’, ‘/foo.html’ %\>

---

<div class="post-metadata">

**Author:** ![cpjolicoeur](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a183cd/32.png) [@cpjolicoeur](https://www.ruby-forum.com/u/cpjolicoeur)\
**Post date:** [December 20, 2006, 8:14pm UTC](https://www.ruby-forum.com/t/link-to-static-html-problem/79999/3 "2006-12-20T20:14:06Z")

</div>

Alex W. wrote:

> Craig J. wrote:
> 
> > link\_to ‘my\_link’, “#{RAILS\_ROOT}/public/foo.html”
> 
> That will create something like:
> 
> [my link](https://www.ruby-forum.com/home/var/www/myapp/public/foo.html)
> 
> this is ibviously not what you want. The link\_to helper only wants the  
> public path to your file, not the absolute path to the file on the disk.  
> You are way over thinking this.
> 
> \<%= link\_to ‘my link’, ‘/foo.html’ %\>

perfect. thanks for the quick response.
