Forum: Ruby on Rails help with RESTful routes

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Fe31c86e61dfabddea38806d2731a9c1?d=identicon&s=25 jon (Guest)
on 2007-04-20 20:13

I have just added a new functions to my RESTful user model
forgot_password that I believe I should now be accessing in the
following url http://localhost:3000/users;forgot_password instead of
/users/forgot_password is this correct?

Secondly reading the agile rails book it is telling me I need to add
somthing to my routes to define this, such as
map.resources :users, :collection => {:forgot_password => :get}
what is the difference between :collection and :member and which one
should I use?

21f7ed21f11a809050594c82eab11d67?d=identicon&s=25 Robert Walker (Guest)
on 2007-04-20 20:55
(Received via mailing list)

:collection applies to collections of your resource.  See the standard
index action:


:member applies to one instance of your resource. See the standard
show action:


If your custom action will return an array of your resource
use :collection  if it return one instance of your resource
use :member.

Also in case your action creates a new instance of your resource
use :new

Also make sure you use the correct method in your custom actions.
Keep REST verbs in mind and use the proper one for the task.


map.resources :users :member => { :disable => :put }



Here we create routes for disabling a member (instance) of User and
are updating it's state to be disabled.  You may want to do something
like this in case other related actions should be taken when a user
gets disabled.  If only the user resource's state changes you can use
the standard routing to update (PUT)  it's new values.
6ef8cb7cd7cd58077f0b57e4fa49a969?d=identicon&s=25 Brian Hogan (Guest)
on 2007-04-20 21:33
(Received via mailing list)

Thanks for taking the time to answer that. That helped me out quite a
Fe31c86e61dfabddea38806d2731a9c1?d=identicon&s=25 jon (Guest)
on 2007-04-21 11:39
cheers, thats explained it pretty well
This topic is locked and can not be replied to.