Hi,
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?
Thanks,
Jon
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
John,
:collection applies to collections of your resource. See the standard
index action:
/users
:member applies to one instance of your resource. See the standard
show action:
/users/1
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.
Example:
map.resources :users :member => { :disable => :put }
creates:
/users/:id;disable
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.
jon wrote:> Hi,
>
> 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?
>
> Thanks,
> Jon
>
> --
> Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
@Robert: Thanks for taking the time to answer that. That helped me out quite a bit. On 4/20/07, Robert Walker <rwalker348-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > John, > > :collection applies to collections of your resource. See the standard > index action: > > /users > > :member applies to one instance of your resource. See the standard > show action: > > /users/1 > > 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. > > Example: > > map.resources :users :member => { :disable => :put } > > creates: > > /users/:id;disable > > 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. > > jon wrote: > > Hi, > > > > 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? > > > > Thanks, > > Jon > > > > -- > > Posted via http://www.ruby-forum.com/. > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
cheers, thats explained it pretty well -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---