How to use RESTful routes

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?

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

:slight_smile:

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. [email protected]

rake routes just help you figure out what is available.