martinlooker
2007-Apr-11 08:15 UTC
Why use :new for own creation actions for restful resources ?
In AWDWR, (pg415), it suggests using the following to allow the custom action to create a new resource: map.resources :articles, :new => { :shortform => :post } resulting in the following url method and path: POST /articles/new;shortform However having new in the url for a standard resource usually presents the form prior to creation at url: GET /articles/new and the posting of the creation actually takes place at the following URL: POST /articles So when adding a custom action to create a resource why not use: map.resource :articles, :collection => { :shortform => :post } which results in a url as follows that more closely matches the standard restful urls? POST /articles;shortform --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jason Roelofs
2007-Apr-11 12:50 UTC
Re: Why use :new for own creation actions for restful resources ?
GET "new" is used to show a form or otherwise give information on how to create an instance of the resource. POST "create" is used to create the actual object. Jason On 4/11/07, martinlooker <martinlooker-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > > In AWDWR, (pg415), it suggests using the following to allow the custom > action to create a new resource: > > map.resources :articles, :new => { :shortform => :post } > > resulting in the following url method and path: > > POST /articles/new;shortform > > However having new in the url for a standard resource usually presents > the form prior to creation at url: > > GET /articles/new > > and the posting of the creation actually takes place at the following > URL: > > POST /articles > > So when adding a custom action to create a resource why not use: > > map.resource :articles, :collection => { :shortform => :post } > > which results in a url as follows that more closely matches the > standard restful urls? > > POST /articles;shortform > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
martinlooker
2007-Apr-12 13:14 UTC
Re: Why use :new for own creation actions for restful resources ?
Jason, thanks for taking the time to reply. I do understand the standard resource routing, however my question is about the ability to add additional custom actions to the standard ones. In particular I am puzzled that the examples of this in AWDWR on page 415 produce urls that do not conform in style to those produced by by the standard routing. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---