Forum: Ruby on Rails Why use :new for own creation actions for restful resources

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.
1d94db56879170906abf47cd3346d82d?d=identicon&s=25 martinlooker (Guest)
on 2007-04-11 10:16
(Received via mailing list)
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

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
83ca41657a99b65d99889abe712ba5e2?d=identicon&s=25 Jason Roelofs (Guest)
on 2007-04-11 14:51
(Received via mailing list)
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.

1d94db56879170906abf47cd3346d82d?d=identicon&s=25 martinlooker (Guest)
on 2007-04-12 15:15
(Received via mailing list)
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.
This topic is locked and can not be replied to.