# RESTful Routing - Difference between new, collection, member

**URL:** <https://www.ruby-forum.com/t/restful-routing-difference-between-new-collection-member/177549>\
**Category:** Rails\
**Created:** [October 20, 2009, 2:14am UTC](https://www.ruby-forum.com/t/restful-routing-difference-between-new-collection-member/177549 "2009-10-20T02:14:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phoenix\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5e9695/32.png) [@Phoenix\_R](https://www.ruby-forum.com/u/Phoenix_R)\
**Post date:** [October 20, 2009, 2:14am UTC](https://www.ruby-forum.com/t/restful-routing-difference-between-new-collection-member/177549/1 "2009-10-20T02:14:03Z")

</div>

I’m re-working an application from scratch to make use of REST-based  
resource routing for the first time. In doing some reading, I found  
the Rails guide ([Rails Routing from the Outside In — Ruby on Rails Guides](http://guides.rubyonrails.org/routing.html)) to be  
really helpful, but I don’t quite understand the difference between  
“new”, “collection” and “member” when defining additional routes on a  
resource. Could somebody clear that up a little - preferably with  
some “real world” examples? The examples in the rails guide seemed  
pretty ambiguous.

---

<div class="post-metadata">

**Author:** ![Phoenix\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5e9695/32.png) [@Phoenix\_R](https://www.ruby-forum.com/u/Phoenix_R)\
**Post date:** [October 20, 2009, 5:35pm UTC](https://www.ruby-forum.com/t/restful-routing-difference-between-new-collection-member/177549/2 "2009-10-20T17:35:50Z")

</div>

Phoenix R. wrote:

> I’m re-working an application from scratch to make use of REST-based  
> resource routing for the first time. In doing some reading, I found  
> the Rails guide ([Rails Routing from the Outside In — Ruby on Rails Guides](http://guides.rubyonrails.org/routing.html)) to be  
> really helpful, but I don’t quite understand the difference between  
> “new”, “collection” and “member” when defining additional routes on a  
> resource. Could somebody clear that up a little - preferably with  
> some “real world” examples? The examples in the rails guide seemed  
> pretty ambiguous.

An action that acts upon a collection of the resource is defined with  
collection and has a route that reflects that:

For example the index action acts upon a collection of the resource:  
GET: /posts

An action that acts upon a single instance of a resource is defined with  
member and has a route that reflects that:

The show, create, update and delete actions are examples:  
GET: /posts/1  
POST: /posts/1  
PUT: /posts/1  
DELETE: /posts/1

An action using ‘new’ also acts upon the collection but allows for  
additional actions that create new instances.

Example:  
map.resources :photos, :new =\> { :upload =\> :post }

Allows Rails to recognize the following request:  
POST: /photos/upload

and route the request to the upload action of the resource’s controller.  
This would be in addition to the ‘normal’ CRUD request:  
POST: /photos

This request could also be used to create new instances of the photos  
resource by routing to the create action.
