I’ve been playing with RESTful Rails on one of my projects. I must admit to being a bit perplexed.
You have to bend your code to get REST working properly, which smells to me.
For example, when editing a model, you need to push a hidden element into your form to spoof a HTTP PUT method. Rails automates some of this, but … why? What do you gain by forcing the system to only accept puts for particular actions, particuarly when browsers need to be tricked into playing nicely? What is lost by having an update action accept POSTs?
Anyway, I will keep playing …
It is too bad that you are confusing implementation details (current browers do not support PUT and DELETE, so *any* RESTful framework that wants to support REST have to do yucky things under the covers.
The most important concept you need to understand in order to “get” REST (heh
is the idea that URIs should be nouns, not verbs. Next most important:
* GET must be idempotent … no side effects from issuing the same GET
more than once
* GET requests with appropriate headers can leverage the fact that
the WWW knows how to cache things for the right amount of time.
* RESTful URIs are bookmarkable — the typical framework based URI is not.
* Even though a browser doesn’t know natively how to do PUT and DELETE,
your application can certainly do that via appropriate XMLHttpRequest calls.
* And, by the way, Flash/Flex/JavaFX/whatever clients can use your same
back end with no problems if you provide RESTful APIs for your services,
instead of just focusing on HTML representations for humans sitting
behind a browser. Rails makes it particularly easy to accomodate this
use case (google for “respond_to”) but it is by no means specific to
this particular framework.
I understand the theory (I’ve actually read Fielding’s work) and I am using, it just feels that I am bending my application in some ways to get it working right.
And hey, I’ve lived through several of these movements. A few years ago everything was in SOAP and RPC was the future.
That said, I think REST is much better architecturally … just be awesome if we didn’t have to resort to hacks.