RESTful interfaces... question.

Hi,

*** I’m going to preface this comment/question with a disclaimer: I’m
really annoyed at this particular second with the buzzwordy-nature of
“REST”, at least in the context of the information I’ve found about it

online. It seems to be an abstract concept that people only pretend
they understand, but they really don’t, so they throw around all of the
same jargon–on pretty much EVERY site about it–as everyone else, when

in reality they don’t really know why they like it or exactly what its
requirements are. Maybe I’m wrong, but that’s my impression and that’s
why I’m annoyed. ***

Okay. In order to simplify my post, let’s just pretend I’m developing a

lightweight social networking site, and I have Users and UserProfiles
(with the obvious has_one association). Is it considered “RESTful” if I
have these following routes? Is the “RESTful” requirement simply that

there is some cacheable URI for each thing for each of the CRUD
operations?

I would really recommend checking out RESTful Web Services by Leonard Richardson and Sam Ruby. It clarifies the subject material quite well.

http://www.oreilly.com/catalog/9780596529260/index.html

In order to really understand the nature of REST you need to put it up
against the alternative.

Here is a link to what convinced me:
http://www.wanderingbarque.com/nonintersecting/2006/11/15/the-s-stands-for-simple/

You could nest them and do something like users/1/profile

--Jeremy

As far as I'm concerned draw the line anywhere you see fit. If you
want a User that has one or many UserProfiles then have at it. In that
case you may want to consider making UserProfile a nested resource of
User, if the case is that UserProfile doesn't make sense on it's own
without being scoped by User. Then you would have a URL like /users/1/
user_profiles/1 if your getting a single resource or /users/1/
user_profiles if your getting the collection. Assuming you're using
the GET method. If you use POST to /users/1/user_profiles then you
would be create a new UserProfile under the User. Of course you'll
also need to make sure you controller actions are setup properly to
assign the new UserProfile to the User.

I don't really see what you feel is so limiting about the RESTful URL.
They are far "prettier" than the traditional ones. Besides that there
is nothing stopping you from using standard or named routes wherever
they make sense. REST adds to Rails, it doesn't really limit it in
any way that I can see.