# Resource Routing

**URL:** <https://www.ruby-forum.com/t/resource-routing/113081>\
**Category:** Rails\
**Created:** [August 27, 2007, 12:03pm UTC](https://www.ruby-forum.com/t/resource-routing/113081 "2007-08-27T12:03:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sjames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c57346/32.png) [@sjames](https://www.ruby-forum.com/u/sjames)\
**Post date:** [August 27, 2007, 12:03pm UTC](https://www.ruby-forum.com/t/resource-routing/113081/1 "2007-08-27T12:03:23Z")

</div>

Hi

Does anyone know anything about the ‘resources’ keyword in routing? I  
can’t find any details on how it works or what it is for, but URLs  
starting ‘resources’ definitely appear to be handled differently from  
other URLs?

Thanks  
Jay

---

<div class="post-metadata">

**Author:** ![sjames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c57346/32.png) [@sjames](https://www.ruby-forum.com/u/sjames)\
**Post date:** [August 27, 2007, 12:30pm UTC](https://www.ruby-forum.com/t/resource-routing/113081/2 "2007-08-27T12:30:49Z")

</div>

James H. wrote:

> Hi
> 
> Does anyone know anything about the ‘resources’ keyword in routing? I  
> can’t find any details on how it works or what it is for, but URLs  
> starting ‘resources’ definitely appear to be handled differently from  
> other URLs?

Perhaps this article will help:

[http://softiesonrails.com/2007/4/18/rest-101-part-4-routing](http://softiesonrails.com/2007/4/18/rest-101-part-4-routing)

–  
Cheers,

- Jacob A.

---

<div class="post-metadata">

**Author:** ![sjames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c57346/32.png) [@sjames](https://www.ruby-forum.com/u/sjames)\
**Post date:** [August 27, 2007, 12:55pm UTC](https://www.ruby-forum.com/t/resource-routing/113081/3 "2007-08-27T12:55:59Z")

</div>

Thanks Jacob, very helpful!

A question, I think it is important that the name of a file is  
maintained in the URL so, for instance, if I uploaded a resource:

my-search-engine-optimised-filename.doc

I would expect it to be available (through the ‘resources’ enhancement)  
here:

map.resources ‘myfiles’

GET:  
[http://www.mydomain.com/myfiles/12345/my-search-engine-optimised-filename.doc](http://www.mydomain.com/myfiles/12345/my-search-engine-optimised-filename.doc)

rather than just:

GET: [http://www.mydomain.com/myfiles/12345](http://www.mydomain.com/myfiles/12345)

Is that something the resources enhancement will support?

Thanks  
Jay

---

<div class="post-metadata">

**Author:** ![sjames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c57346/32.png) [@sjames](https://www.ruby-forum.com/u/sjames)\
**Post date:** [August 27, 2007, 1:01pm UTC](https://www.ruby-forum.com/t/resource-routing/113081/4 "2007-08-27T13:01:51Z")

</div>

James H. wrote:

> map.resources ‘myfiles’
> 
> GET:  
> [http://www.mydomain.com/myfiles/12345/my-search-engine-optimised-filename.doc](http://www.mydomain.com/myfiles/12345/my-search-engine-optimised-filename.doc)
> 
> rather than just:
> 
> GET: [http://www.mydomain.com/myfiles/12345](http://www.mydomain.com/myfiles/12345)
> 
> Is that something the resources enhancement will support?

Well, the resource identifier (12345) is just an identifier. It could  
just as well be “some-crazy-filename.doc”. It will be put into the  
params[:id] string. I believe there is a Railscast episode about this,  
check out [railscasts.com](http://railscasts.com).

–  
Cheers,

- Jacob A.

---

<div class="post-metadata">

**Author:** ![sjames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c57346/32.png) [@sjames](https://www.ruby-forum.com/u/sjames)\
**Post date:** [August 27, 2007, 1:17pm UTC](https://www.ruby-forum.com/t/resource-routing/113081/5 "2007-08-27T13:17:08Z")

</div>

Hi Jacob

Thanks for your help, I’ll check out the [railscasts.com](http://railscasts.com) site.

Just a note though, I need to keep the identifier, so that there can be  
more than one file of the same name. The identifier will then help me to  
find the correct entry in the database.

Cheers  
Jay
