<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">HI Dan,<DIV><BR><DIV><DIV>On Nov 3, 2005, at 11:50 PM, Dan Kubb wrote:</DIV><BLOCKQUOTE type="cite"><P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">I've been thinking about how to RESTify Rails for the</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">last week, and have been RESTifying other MVC systems</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">for several months, so I've got a few points to add.</FONT></P> </BLOCKQUOTE></DIV><DIV><BR class="khtml-block-placeholder"></DIV>Wow, great stuff. I've added your new items to the Wiki:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><A href="http://microformats.org/wiki/rest/rails">http://microformats.org/wiki/rest/rails</A></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I just hope we don't freak out David with too many ideas. :-) I appreciate your willingness to actually prototype this in code, so (assuming David agrees) the implementation should be relatively painless.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>My only concern is with your mechanism for handling other methods:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "> GET /person/ -> Person.get_index</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "> GET /person/123 -> Person.get_index</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "> GET /person/123/friend -> Person.get_friend</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "> HEAD /person/ -> Person.get_index # HEAD handled by get method</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "> POST /person/ -> Person.post_index</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "> PUT /person/123 -> Person.put_index</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "> POST /person/123/friend -> Person.post_friend</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "> DELETE /person/123 -> Person.delete_index</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "> DELETE /person/123/friend -> Person.delete_friend</DIV></BLOCKQUOTE></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>That seems a bit verbose, not to mention non-backward-compatible. I'd prefer something like:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "> GET /person/123 -> Person.index</DIV></BLOCKQUOTE><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "> POST /person/123 -> Person.index_POST</DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV><DIV>That is, the default is GET as usual, but one can suffix a method to indicate a special response. I also think using ALL CAPS is better to a) avoid collision with normal URIs and b) signal clearly that this is special. Though, is CAPS in a method name bad Ruby hygiene?</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Also, one question:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">One other thing this Controller is doing is that it</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">allows tunneling of PUT, DELETE (and any other method) over</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">top of a POST. Before dispatch I look for a specific</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">parameter that says what method I really want to call</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">and dispatch to it.</DIV></BLOCKQUOTE></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Yeah, we're still wrestling with that issue.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">While this isn't RESTful, its a trade-off that will allow</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">the web apps to work with all browsers until support</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">for more than GET and POST is common.</DIV></BLOCKQUOTE><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Actually, there might be another way -- automatically insert the necessary JavaScript to synthesize the request from a form:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="http://jibbering.com/2002/4/httprequest.html">http://jibbering.com/2002/4/httprequest.html</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">If we're controlling the generated HTML anyway, why not solve it on the client-side? This is a browser limitation, so better to fix it there; and if from the designer's point of view it is zero-cost why not pretend to do the right thing?</DIV><BR><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "> Hey I've got to tunnel update and delete operations over POST somehow</DIV></BLOCKQUOTE></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Well, Dimitri might disagree. :-) </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">anyway, so I figure I'll use a convention to do it.</DIV></BLOCKQUOTE><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">So, what convention to you use, exactly? Explicitly specifying a "put_index" URI?</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">-- Ernie P.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><BR class="khtml-block-placeholder"></DIV><DIV><BR><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV>------------ </DIV><DIV>Ernest N. Prabhakar, Ph.D. <drernie at opendarwin.org></DIV><DIV>Ex-Physicist, Marketing Weenie, and Dilettante Hacker</DIV><DIV>Probe-Hacker blog: <A href="http://www.opendarwin.org/~drernie/">http://www.opendarwin.org/~drernie/</A></DIV><BR class="Apple-interchange-newline"></SPAN> </DIV><BR></DIV></BODY></HTML>