[uf-rest] RESTifying RAILs

David Heinemeier Hansson david at loudthinking.com
Sun Nov 6 04:08:50 PST 2005


> Another way it would help is for responding to non-handled
> HTTP methods.  If a request comes in for a known, but non-handled
> method a "405 Method Not Allowed" could be returned.  For
> completely unknown HTTP methods a "501 Not Implemented" can
> be returned.  While both of these checks can be done within a
> case statement, there would be less duplication if we check
> these things in the routing stage.

Aight, I buy that. Round 2:

class PeopleController
   verbs_for :person do
     def post
     end

     def get
     end
   end

   verbs_for :friend do
     def post
     end

     def get
     end
   end
end

This would internally get translated to something like:

class PeopleController
   def person
     # check for methods, standard responses
     # delegate to person_verb_post when person is request through POST
   end

   private
     def person_verb_post
     end
end

> class PersonController < ActiveController::Base
>   limit_method :post, :put, :delete, :role => :admin_user
>
>   # ...
> end

We actually already have this with verify:

class PersonController
   verify :only    => [ :person, :friend ],
          :method  => [ :post, :put, :delete ],
          :session => :admin_user
end
--
David Heinemeier Hansson
http://www.37signals.com    -- Basecamp, Backpack, Writeboard, Tada
http://www.loudthinking.com -- Broadcasting Brain
http://www.rubyonrails.com  -- Web-application framework




More information about the microformats-rest mailing list