Rails is Web Architecture Friendly

I created a new Rails project today, using Rails 1.1 for the first time. There’s a little gem inside Controllers created by the scaffolding:

# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
verify :method => :post, :only => [ :destroy, :create, :update ],
:redirect_to => { :action => :list }

Not only is that so terse and simple to express in Ruby on Rails, but it’s the right thing to do. Any action that may result in modification of the resource should be performed with POST.

It’s great to see these types of Web Architecture best practices enforced, so that more applications are built with web friendliness.

2 Responses to “Rails is Web Architecture Friendly”

  1. Henry Story Says:

    not quite right. You madify a resource with PUT, and create a resource with POST. You delete a resource with DELETE

    Henry

  2. sethladd Says:

    That’s probably a matter of taste. According to http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html, the PUT method can create a new resource at the specified URI. As long as the server allows for that, of course. POST can be used to create a resource, if the URI that you are posting to follows the semantics of some sort of container. No doubt, you can use either to create a new resource. With POST, though, the server is responsible for the creation of the URI. With PUT, the client is responsible, and it usually not in a position to create a good URI.

Leave a Reply