# Excluding routes from a resource declaration

**URL:** <https://www.ruby-forum.com/t/excluding-routes-from-a-resource-declaration/128139>\
**Category:** Rails\
**Created:** [February 5, 2008, 10:19am UTC](https://www.ruby-forum.com/t/excluding-routes-from-a-resource-declaration/128139 "2008-02-05T10:19:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ke\_han](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/839c29/32.png) [@ke\_han](https://www.ruby-forum.com/u/ke_han)\
**Post date:** [February 5, 2008, 10:19am UTC](https://www.ruby-forum.com/t/excluding-routes-from-a-resource-declaration/128139/1 "2008-02-05T10:19:55Z")

</div>

I’m working with restful\_authentication plugin and note that it adds  
the following to routes.rb:

map.resource :session

This assumes I named my controller in the singular, which I did. The  
above resource creates the following routes copied from “rake routes”  
output):

```
                   POST /session

```

{:controller=\>“sessions”, :action=\>“create”}  
POST /session.:format  
{:controller=\>“sessions”, :action=\>“create”}  
new\_session GET /session/new  
{:controller=\>“sessions”, :action=\>“new”}  
formatted\_new\_session GET /session/new.:format  
{:controller=\>“sessions”, :action=\>“new”}  
edit\_session GET /session/edit  
{:controller=\>“sessions”, :action=\>“edit”}  
formatted\_edit\_session GET /session/edit.:format  
{:controller=\>“sessions”, :action=\>“edit”}  
session GET /session  
{:controller=\>“sessions”, :action=\>“show”}  
formatted\_session GET /session.:format  
{:controller=\>“sessions”, :action=\>“show”}  
PUT /session  
{:controller=\>“sessions”, :action=\>“update”}  
PUT /session.:format  
{:controller=\>“sessions”, :action=\>“update”}  
DELETE /session  
{:controller=\>“sessions”, :action=\>“destroy”}  
DELETE /session.:format  
{:controller=\>“sessions”, :action=\>“destroy”}

Lovely…thats three actions too many. I don’t want half these.  
Specifically, these:

```
      edit_session GET /session/edit

```

{:controller=\>“sessions”, :action=\>“edit”}  
formatted\_edit\_session GET /session/edit.:format  
{:controller=\>“sessions”, :action=\>“edit”}  
session GET /session  
{:controller=\>“sessions”, :action=\>“show”}  
formatted\_session GET /session.:format  
{:controller=\>“sessions”, :action=\>“show”}  
PUT /session  
{:controller=\>“sessions”, :action=\>“update”}  
PUT /session.:format  
{:controller=\>“sessions”, :action=\>“update”}

should not exist. This is my SessionController. Pretty important  
stuff. Of course, my controller won’t have code to handle the above  
actions and I won’t have views for them. But I also don’t want routes  
for them either.

What’s the best way to exclude some and still have fully qualified  
RESTful routes for the routes I do want??

thanks, Jon

> **[ShellShadow \> Trusted Server Support](https://shellshadow.com/)**
>
> Trusted Support, secure command line support tool
