# I want most, but not all routes created by map.resources

**URL:** <https://www.ruby-forum.com/t/i-want-most-but-not-all-routes-created-by-map-resources/111562>\
**Category:** Rails\
**Created:** [August 8, 2007, 4:39pm UTC](https://www.ruby-forum.com/t/i-want-most-but-not-all-routes-created-by-map-resources/111562 "2007-08-08T16:39:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a8b319/32.png) [@ryan](https://www.ruby-forum.com/u/ryan)\
**Post date:** [August 8, 2007, 4:39pm UTC](https://www.ruby-forum.com/t/i-want-most-but-not-all-routes-created-by-map-resources/111562/1 "2007-08-08T16:39:30Z")

</div>

How do I do that?

I’m my case, I don’t want GET /resource/:id;edit and DELETE /  
resource/:id

;edit is not needed for my app, and DELETE is not allowed.

Do I have create all the routes by hand? Or can I pass some kind of  
except parameter to map.resources?

Ryan

---

<div class="post-metadata">

**Author:** ![ryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a8b319/32.png) [@ryan](https://www.ruby-forum.com/u/ryan)\
**Post date:** [August 8, 2007, 4:46pm UTC](https://www.ruby-forum.com/t/i-want-most-but-not-all-routes-created-by-map-resources/111562/2 "2007-08-08T16:46:37Z")

</div>

You can pass restricted:  
:restricted=\>/new|create/

---

<div class="post-metadata">

**Author:** ![ryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a8b319/32.png) [@ryan](https://www.ruby-forum.com/u/ryan)\
**Post date:** [August 9, 2007, 4:01pm UTC](https://www.ruby-forum.com/t/i-want-most-but-not-all-routes-created-by-map-resources/111562/3 "2007-08-09T16:01:09Z")

</div>

On Aug 8, 6:44 pm, Jeff [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Another approach is to go ahead an proactively implement controller  
> actions for those that shouldn’t be called, and return a 401 status or  
> something appropriate, by calling the “head” method to return a status  
> code.
> 
> Jeff

This is the approach I have taken. Thanks for the inputs.

---

<div class="post-metadata">

**Author:** ![ryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a8b319/32.png) [@ryan](https://www.ruby-forum.com/u/ryan)\
**Post date:** [August 9, 2007, 1:44am UTC](https://www.ruby-forum.com/t/i-want-most-but-not-all-routes-created-by-map-resources/111562/4 "2007-08-09T01:44:40Z")

</div>

On Aug 8, 2:18 pm, Josh S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> You can just ignore them. If you don’t implement the #edit and #destroy  
> actions in your controller, the routes won’t do anything. I’ve thought  
> about an :only or :except option for map.resources, but it seems like  
> overkill.

I agree.

Another approach is to go ahead an proactively implement controller  
actions for those that shouldn’t be called, and return a 401 status or  
something appropriate, by calling the “head” method to return a status  
code.

Jeff

---

<div class="post-metadata">

**Author:** ![ryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a8b319/32.png) [@ryan](https://www.ruby-forum.com/u/ryan)\
**Post date:** [August 8, 2007, 9:18pm UTC](https://www.ruby-forum.com/t/i-want-most-but-not-all-routes-created-by-map-resources/111562/5 "2007-08-08T21:18:49Z")

</div>

Ryan wrote:

> How do I do that?
> 
> I’m my case, I don’t want GET /resource/:id;edit and DELETE /  
> resource/:id
> 
> ;edit is not needed for my app, and DELETE is not allowed.
> 
> Do I have create all the routes by hand? Or can I pass some kind of  
> except parameter to map.resources?
> 
> Ryan

You can just ignore them. If you don’t implement the #edit and #destroy  
actions in your controller, the routes won’t do anything. I’ve thought  
about an :only or :except option for map.resources, but it seems like  
overkill. If the presence of the superfluous routes really offends you,  
you could remove them from the routes array with a bit of hackery, but  
aside from a few more CPU cycles to not match the routes, they aren’t  
hurting anyone by being there.

–  
Josh S.  
[http://blog.hasmanythrough.com](http://blog.hasmanythrough.com)
