# RESTful routes and Mime::Type

**URL:** <https://www.ruby-forum.com/t/restful-routes-and-mime-type/81955>\
**Category:** Rails\
**Created:** [January 16, 2007, 2:54pm UTC](https://www.ruby-forum.com/t/restful-routes-and-mime-type/81955 "2007-01-16T14:54:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_De\_Berdt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/53a042/32.png) [@Peter\_De\_Berdt](https://www.ruby-forum.com/u/Peter_De_Berdt)\
**Post date:** [January 16, 2007, 2:54pm UTC](https://www.ruby-forum.com/t/restful-routes-and-mime-type/81955/1 "2007-01-16T14:54:40Z")

</div>

Hi all

I’m using RESTful routes combined with the to\_csv plugin and would  
like to know if there’s a nicer way of generating a link to fetch the  
CSV file than just making a hard link. This is what I use for the  
moment (and it works btw):

\<%= link\_to(“Export as CSV”,"/companies.csv") -%\>

I would expect the link helper to have something like

\<%= link\_to(“Export as CSV”,companies\_url(:type =\> :csv) -%\>

but haven’t found anything in the rails docs to generate the URL in  
this way.

Best regards

Peter De Berdt

---

<div class="post-metadata">

**Author:** ![Peter\_De\_Berdt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/53a042/32.png) [@Peter\_De\_Berdt](https://www.ruby-forum.com/u/Peter_De_Berdt)\
**Post date:** [January 16, 2007, 3:46pm UTC](https://www.ruby-forum.com/t/restful-routes-and-mime-type/81955/2 "2007-01-16T15:46:08Z")

</div>

On 1/16/07, Peter De Berdt [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> \<%= link\_to(“Export as CSV”,companies\_url(:type =\> :csv) -%\>
> 
> but haven’t found anything in the rails docs to generate the URL in this  
> way.

formatted\_companies\_url(:format =\> :csv)

–  
Rick O.  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)

---

<div class="post-metadata">

**Author:** ![Peter\_De\_Berdt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/53a042/32.png) [@Peter\_De\_Berdt](https://www.ruby-forum.com/u/Peter_De_Berdt)\
**Post date:** [January 16, 2007, 4:05pm UTC](https://www.ruby-forum.com/t/restful-routes-and-mime-type/81955/3 "2007-01-16T16:05:16Z")

</div>

On 16 Jan 2007, at 15:45, Rick O. wrote:

> > I would expect the link helper to have something like
> > 
> > \<%= link\_to(“Export as CSV”,companies\_url(:type =\> :csv) -%\>
> > 
> > but haven’t found anything in the rails docs to generate the URL  
> > in this  
> > way.
> 
> formatted\_companies\_url(:format =\> :csv)

Thanks! Working perfectly, simple… but undocumented.

Best regards

Peter De Berdt
