# Linking to Files( ie. PDF, DOC etc... )

**URL:** <https://www.ruby-forum.com/t/linking-to-files-ie-pdf-doc-etc/119515>\
**Category:** Rails\
**Created:** [November 7, 2007, 5:37pm UTC](https://www.ruby-forum.com/t/linking-to-files-ie-pdf-doc-etc/119515 "2007-11-07T17:37:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sw0rdfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/edb3f5/32.png) [@sw0rdfish](https://www.ruby-forum.com/u/sw0rdfish)\
**Post date:** [November 7, 2007, 5:37pm UTC](https://www.ruby-forum.com/t/linking-to-files-ie-pdf-doc-etc/119515/1 "2007-11-07T17:37:39Z")

</div>

Ok this is probably a silly question, but is there some special way to  
link to files?

I have a directory of files that I want my software to automatically  
display for download. These are forms of different types, some are  
PDFs, some are DOCs etc.

When I click on the link I create, it appears to be going to the  
correct filename / url but I get the following error.

no route found to match “/forms/filename.doc” with {:method=\>:get}

DO I need to use a specific type of link? I link\_to the file as such.

\<%= link\_to file[0, file.length-4], “forms/”+ file %\>

where file is the filename.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![sw0rdfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/edb3f5/32.png) [@sw0rdfish](https://www.ruby-forum.com/u/sw0rdfish)\
**Post date:** [November 7, 2007, 5:58pm UTC](https://www.ruby-forum.com/t/linking-to-files-ie-pdf-doc-etc/119515/2 "2007-11-07T17:58:45Z")

</div>

On Nov 7, 2007 11:36 AM, sw0rdfish [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> no route found to match “/forms/filename.doc” with {:method=\>:get}
> 
> DO I need to use a specific type of link? I link\_to the file as such.
> 
> \<%= link\_to file[0, file.length-4], “forms/”+ file %\>
> 
> where file is the filename.

Where are the files? They should be in public/forms under your Rails  
application root.

---

<div class="post-metadata">

**Author:** ![sw0rdfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/edb3f5/32.png) [@sw0rdfish](https://www.ruby-forum.com/u/sw0rdfish)\
**Post date:** [November 7, 2007, 7:08pm UTC](https://www.ruby-forum.com/t/linking-to-files-ie-pdf-doc-etc/119515/3 "2007-11-07T19:08:59Z")

</div>

yeah I was reading from forms/ instead of public/forms

I’m an idiot… Thanks Bob,.
