# Restful routing link\_to format

**URL:** <https://www.ruby-forum.com/t/restful-routing-link-to-format/138596>\
**Category:** Rails\
**Created:** [May 25, 2008, 2:16pm UTC](https://www.ruby-forum.com/t/restful-routing-link-to-format/138596 "2008-05-25T14:16:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![roa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e7dd6/32.png) [@roa](https://www.ruby-forum.com/u/roa)\
**Post date:** [May 25, 2008, 2:16pm UTC](https://www.ruby-forum.com/t/restful-routing-link-to-format/138596/1 "2008-05-25T14:16:38Z")

</div>

Hi,

I can’t seem to find how to define the format in my links. My link looks  
like this now:

\<%= link\_to ‘Show’, resource\_path(@resource) %\>

But how do I specify the format? Do I realy need to create the url  
myself?

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![roa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e7dd6/32.png) [@roa](https://www.ruby-forum.com/u/roa)\
**Post date:** [May 25, 2008, 2:23pm UTC](https://www.ruby-forum.com/t/restful-routing-link-to-format/138596/2 "2008-05-25T14:23:04Z")

</div>

resource\_path(@resource, :format =\> :xml)  
On Sun, May 25, 2008 at 9:46 PM, Michael R. \<  
removed\_email\_address@domain.invalid\> wrote:

> ## Thank you in advance.
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Appreciated my help?  
Recommend me on Working With Rails  
[http://workingwithrails.com/person/11030-ryan-bigg](http://workingwithrails.com/person/11030-ryan-bigg)

---

<div class="post-metadata">

**Author:** ![roa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e7dd6/32.png) [@roa](https://www.ruby-forum.com/u/roa)\
**Post date:** [May 25, 2008, 3:01pm UTC](https://www.ruby-forum.com/t/restful-routing-link-to-format/138596/3 "2008-05-25T15:01:51Z")

</div>

if you do rake routes you should see there are a bunch of additional  
routes like

formatted\_resource\_path

you can use those to specify a path to an xml, rss etc file e.g.

link\_to(‘Show XML’, formatted\_resource\_path(@resource, :format  
=\> :xml))

Think that should work…

Joe

On May 25, 1:34 pm, Michael R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![roa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e7dd6/32.png) [@roa](https://www.ruby-forum.com/u/roa)\
**Post date:** [May 25, 2008, 2:34pm UTC](https://www.ruby-forum.com/t/restful-routing-link-to-format/138596/4 "2008-05-25T14:34:25Z")

</div>

Ok, I thought is was this way. But how can I get the url format like

xxx.xml and not like

xxx?format=xml ?

I have

map.connect ‘:controller/:action/:id.:format’

specified in my routes.rb

Thank you for the quick reply btw
