Consistency in REST-routes naming

Hello everyone!

In working with the Rails-REST-features I have always wondered about
the URL for the new-action

/objects/new

In REST the URL should represent a Resource. As the semicolon is for
adding non-standard actions (verbs) to a resource, IMHO it should be:

/objects;new
and not
/objects/new

In fact, this is just like an additional action, which I would specify
with the :collection-parameter:

map.resources :objects, :collection => { :special_action => :get }

which would look like
/objects;special_action
and not like
/objects/special_action

Also the edit-action is implemented this way:
/objects/1;edit

What do you think?

Have a nice day,

Michael

"/objects;new" would refer to listing a collection of objects with a
"new" aspect. "/objects/new" means that it should show one object with
that does not have an id. Make any sense?

DHH has done his research and its definitely right the way it is. I
thought it was odd the first time I saw it too.

The problem is that you're thinking in terms of the database, when you
need to be thinking in terms of resources. When you request
/objects/1, you're not getting an object from the db that has an id of
1, but simply requesting an object identified by "1". Then you do
something interesting with it. The underlying implementation doesn't
matter one bit, nor should it. We're using the web, where everything
is a resource.

In the same vein, when you request /objects/new you're not requesting
a new object, nor are you making an RPC call to Object.new. All
you're doing is requesting the resource identified by /objects/new.
The difference between this resource and the /objects/1 from earlier
is that, by convention, you can't update this particular resource.
This isn't really a web convention, but rather one that Rails gives
you with the default code. You could just as easily write some code
that WOULD allow you to update the resource at /objects/new.

This may seem a bit confusing, and it's likely because I'm not a very
eloquent writer. However it's important that you recognize the
paradigm here - it's not about databases, it's not about procedures,
it's about resources. I recommend reading DHH's "A World of
Resources" [1] and Alex Bunardzic's various blog posts on resources
[2]. Hopefully they'll help it click for you, as well help you
recognize the importance of this approach.

Pat

[1] http://www.loudthinking.com/arc/000593.html
[2] http://jooto.com/blog/index.php/category/resource-oriented-architecture/

Thank you for your answers!

I understand your argumentation, although I think one could argue it
also the other way round.

PUT /objects/1 updates the object
as we have no standard-verb to get the form we use
GET /objects/1;edit

IMHO this would be in the same spirit as the relation between
POST /objects
GET /objects;new

and in fact this is exactly the syntax DHH used in the presentation
you mentioned (look on page 18)

But of course I also understand the argumentation with /objects/new
being it's own resource and have no problem with this syntax. For me
the ";new"-syntax is just a bit more self-explanatory, I would see the
new-form as an aspect of the collection, as the edit-form is an aspect
of the member).

Michael