# How to use RESTful routes

**URL:** <https://www.ruby-forum.com/t/how-to-use-restful-routes/126414>\
**Category:** Rails\
**Created:** [January 18, 2008, 4:02am UTC](https://www.ruby-forum.com/t/how-to-use-restful-routes/126414 "2008-01-18T04:02:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kopf1988](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/74df32/32.png) [@kopf1988](https://www.ruby-forum.com/u/kopf1988)\
**Post date:** [January 18, 2008, 4:02am UTC](https://www.ruby-forum.com/t/how-to-use-restful-routes/126414/1 "2008-01-18T04:02:22Z")

</div>

Okay, this has come up before… but it is NOT working for me _sigh_  
but, I’m hoping someone can tell me why. (Rails version 1.2.6)

Let’s say I want to create an off the wall method in my Users  
controller, called login. I also create the view for this action,  
login.erb. My first problem was that /users/login did not work (rails  
mistook login for being :id). So that was fixed with:

map.resources :users, :collection =\> {:login =\> :get }

But now, I want my users to be able to click login from the homepage,  
simple enough? But this RESTful link generates a no method error.

\<%= link\_to ‘Login’, login\_users\_path %\>

What have I missed/why does this not work?

---

<div class="post-metadata">

**Author:** ![kopf1988](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/74df32/32.png) [@kopf1988](https://www.ruby-forum.com/u/kopf1988)\
**Post date:** [January 18, 2008, 4:07am UTC](https://www.ruby-forum.com/t/how-to-use-restful-routes/126414/2 "2008-01-18T04:07:34Z")

</div>

kopf1988 wrote:

> Okay, this has come up before… but it is NOT working for me _sigh_  
> but, I’m hoping someone can tell me why. (Rails version 1.2.6)
> 
> Let’s say I want to create an off the wall method in my Users  
> controller, called login. I also create the view for this action,  
> login.erb. My first problem was that /users/login did not work (rails  
> mistook login for being :id). So that was fixed with:
> 
> map.resources :users, :collection =\> {:login =\> :get }
> 
> But now, I want my users to be able to click login from the homepage,  
> simple enough? But this RESTful link generates a no method error.
> 
> \<%= link\_to ‘Login’, login\_users\_path %\>
> 
> What have I missed/why does this not work?

$ rake routes

🙂

---

<div class="post-metadata">

**Author:** ![kopf1988](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/74df32/32.png) [@kopf1988](https://www.ruby-forum.com/u/kopf1988)\
**Post date:** [January 18, 2008, 4:12am UTC](https://www.ruby-forum.com/t/how-to-use-restful-routes/126414/3 "2008-01-18T04:12:18Z")

</div>

Do I have to run that? Does that change any files that I can just  
upload themselves? I can’t just go around raking things on my shared  
host…

Results of my rake routes:  
web\_pages GET /web\_pages  
{:action=\>“index”, :controller=\>“web\_pages”}  
formatted\_web\_pages GET /web\_pages.:format  
{:action=\>“index”, :controller=\>“web\_pages”}  
POST /web\_pages  
{:action=\>“create”, :controller=\>“web\_pages”}  
POST /web\_pages.:format  
{:action=\>“create”, :controller=\>“web\_pages”}  
new\_web\_page GET /web\_pages/new  
{:action=\>“new”, :controller=\>“web\_pages”}  
formatted\_new\_web\_page GET /web\_pages/new.:format  
{:action=\>“new”, :controller=\>“web\_pages”}  
edit\_web\_page GET /web\_pages/:id/edit  
{:action=\>“edit”, :controller=\>“web\_pages”}  
GET /web\_pages/:id;edit  
{:action=\>“edit”, :controller=\>“web\_pages”}  
GET /web\_pages/:id.:format;edit  
{:action=\>“edit”, :controller=\>“web\_pages”}  
formatted\_edit\_web\_page GET /web\_pages/:id/edit.:format  
{:action=\>“edit”, :controller=\>“web\_pages”}  
web\_page GET /web\_pages/:id  
{:action=\>“show”, :controller=\>“web\_pages”}  
formatted\_web\_page GET /web\_pages/:id.:format  
{:action=\>“show”, :controller=\>“web\_pages”}  
PUT /web\_pages/:id  
{:action=\>“update”, :controller=\>“web\_pages”}  
PUT /web\_pages/:id.:format  
{:action=\>“update”, :controller=\>“web\_pages”}  
DELETE /web\_pages/:id  
{:action=\>“destroy”, :controller=\>“web\_pages”}  
DELETE /web\_pages/:id.:format  
{:action=\>“destroy”, :controller=\>“web\_pages”}  
websites GET /websites  
{:action=\>“index”, :controller=\>“websites”}  
formatted\_websites GET /websites.:format  
{:action=\>“index”, :controller=\>“websites”}  
POST /websites  
{:action=\>“create”, :controller=\>“websites”}  
POST /websites.:format  
{:action=\>“create”, :controller=\>“websites”}  
new\_website GET /websites/new  
{:action=\>“new”, :controller=\>“websites”}  
formatted\_new\_website GET /websites/new.:format  
{:action=\>“new”, :controller=\>“websites”}  
edit\_website GET /websites/:id/edit  
{:action=\>“edit”, :controller=\>“websites”}  
GET /websites/:id;edit  
{:action=\>“edit”, :controller=\>“websites”}  
GET /websites/:id.:format;edit  
{:action=\>“edit”, :controller=\>“websites”}  
formatted\_edit\_website GET /websites/:id/edit.:format  
{:action=\>“edit”, :controller=\>“websites”}  
website GET /websites/:id  
{:action=\>“show”, :controller=\>“websites”}  
formatted\_website GET /websites/:id.:format  
{:action=\>“show”, :controller=\>“websites”}  
PUT /websites/:id  
{:action=\>“update”, :controller=\>“websites”}  
PUT /websites/:id.:format  
{:action=\>“update”, :controller=\>“websites”}  
DELETE /websites/:id  
{:action=\>“destroy”, :controller=\>“websites”}  
DELETE /websites/:id.:format  
{:action=\>“destroy”, :controller=\>“websites”}  
pictures GET /pictures  
{:action=\>“index”, :controller=\>“pictures”}  
formatted\_pictures GET /pictures.:format  
{:action=\>“index”, :controller=\>“pictures”}  
POST /pictures  
{:action=\>“create”, :controller=\>“pictures”}  
POST /pictures.:format  
{:action=\>“create”, :controller=\>“pictures”}  
new\_picture GET /pictures/new  
{:action=\>“new”, :controller=\>“pictures”}  
formatted\_new\_picture GET /pictures/new.:format  
{:action=\>“new”, :controller=\>“pictures”}  
edit\_picture GET /pictures/:id/edit  
{:action=\>“edit”, :controller=\>“pictures”}  
GET /pictures/:id;edit  
{:action=\>“edit”, :controller=\>“pictures”}  
GET /pictures/:id.:format;edit  
{:action=\>“edit”, :controller=\>“pictures”}  
formatted\_edit\_picture GET /pictures/:id/edit.:format  
{:action=\>“edit”, :controller=\>“pictures”}  
picture GET /pictures/:id  
{:action=\>“show”, :controller=\>“pictures”}  
formatted\_picture GET /pictures/:id.:format  
{:action=\>“show”, :controller=\>“pictures”}  
PUT /pictures/:id  
{:action=\>“update”, :controller=\>“pictures”}  
PUT /pictures/:id.:format  
{:action=\>“update”, :controller=\>“pictures”}  
DELETE /pictures/:id  
{:action=\>“destroy”, :controller=\>“pictures”}  
DELETE /pictures/:id.:format  
{:action=\>“destroy”, :controller=\>“pictures”}  
galleries GET /galleries  
{:action=\>“index”, :controller=\>“galleries”}  
formatted\_galleries GET /galleries.:format  
{:action=\>“index”, :controller=\>“galleries”}  
POST /galleries  
{:action=\>“create”, :controller=\>“galleries”}  
POST /galleries.:format  
{:action=\>“create”, :controller=\>“galleries”}  
new\_gallery GET /galleries/new  
{:action=\>“new”, :controller=\>“galleries”}  
formatted\_new\_gallery GET /galleries/new.:format  
{:action=\>“new”, :controller=\>“galleries”}  
edit\_gallery GET /galleries/:id/edit  
{:action=\>“edit”, :controller=\>“galleries”}  
GET /galleries/:id;edit  
{:action=\>“edit”, :controller=\>“galleries”}  
GET /galleries/:id.:format;edit  
{:action=\>“edit”, :controller=\>“galleries”}  
formatted\_edit\_gallery GET /galleries/:id/edit.:format  
{:action=\>“edit”, :controller=\>“galleries”}  
gallery GET /galleries/:id  
{:action=\>“show”, :controller=\>“galleries”}  
formatted\_gallery GET /galleries/:id.:format  
{:action=\>“show”, :controller=\>“galleries”}  
PUT /galleries/:id  
{:action=\>“update”, :controller=\>“galleries”}  
PUT /galleries/:id.:format  
{:action=\>“update”, :controller=\>“galleries”}  
DELETE /galleries/:id  
{:action=\>“destroy”, :controller=\>“galleries”}  
DELETE /galleries/:id.:format  
{:action=\>“destroy”, :controller=\>“galleries”}  
modify\_users /users/modify  
{:action=\>“modify”, :controller=\>“users”}  
/users;modify  
{:action=\>“modify”, :controller=\>“users”}  
/users.:format;modify  
{:action=\>“modify”, :controller=\>“users”}  
formatted\_modify\_users /users/modify.:format  
{:action=\>“modify”, :controller=\>“users”}  
login\_users GET /users/login  
{:action=\>“login”, :controller=\>“users”}  
GET /users;login  
{:action=\>“login”, :controller=\>“users”}  
GET /users.:format;login  
{:action=\>“login”, :controller=\>“users”}  
formatted\_login\_users GET /users/login.:format  
{:action=\>“login”, :controller=\>“users”}  
logout\_users GET /users/logout  
{:action=\>“logout”, :controller=\>“users”}  
GET /users;logout  
{:action=\>“logout”, :controller=\>“users”}  
GET /users.:format;logout  
{:action=\>“logout”, :controller=\>“users”}  
formatted\_logout\_users GET /users/logout.:format  
{:action=\>“logout”, :controller=\>“users”}  
users GET /users  
{:action=\>“index”, :controller=\>“users”}  
formatted\_users GET /users.:format  
{:action=\>“index”, :controller=\>“users”}  
POST /users  
{:action=\>“create”, :controller=\>“users”}  
POST /users.:format  
{:action=\>“create”, :controller=\>“users”}  
new\_user GET /users/new  
{:action=\>“new”, :controller=\>“users”}  
formatted\_new\_user GET /users/new.:format  
{:action=\>“new”, :controller=\>“users”}  
edit\_user GET /users/:id/edit  
{:action=\>“edit”, :controller=\>“users”}  
GET /users/:id;edit  
{:action=\>“edit”, :controller=\>“users”}  
GET /users/:id.:format;edit  
{:action=\>“edit”, :controller=\>“users”}  
formatted\_edit\_user GET /users/:id/edit.:format  
{:action=\>“edit”, :controller=\>“users”}  
user GET /users/:id  
{:action=\>“show”, :controller=\>“users”}  
formatted\_user GET /users/:id.:format  
{:action=\>“show”, :controller=\>“users”}  
PUT /users/:id  
{:action=\>“update”, :controller=\>“users”}  
PUT /users/:id.:format  
{:action=\>“update”, :controller=\>“users”}  
DELETE /users/:id  
{:action=\>“destroy”, :controller=\>“users”}  
DELETE /users/:id.:format  
{:action=\>“destroy”, :controller=\>“users”}  
/:controller/service.wsdl  
{:action=\>“wsdl”}  
/:controller/:action/:id.:format  
/:controller/:action/:id

On Jan 17, 9:07 pm, Russ J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![kopf1988](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/74df32/32.png) [@kopf1988](https://www.ruby-forum.com/u/kopf1988)\
**Post date:** [January 18, 2008, 5:24am UTC](https://www.ruby-forum.com/t/how-to-use-restful-routes/126414/4 "2008-01-18T05:24:14Z")

</div>

rake routes just help you figure out what is available.
