[uf-rest] Instance/Collection URL conventions

David Heinemeier Hansson david at loudthinking.com
Thu Nov 10 06:14:22 PST 2005


> I see the makings of a RESTifarian plugin shape up quickly ;)

Okay, I couldn't wait so I went ahead and created it.

If you do script/plugin install restifarian, you'll get the start of  
this. (You need beta gems/edge rails for this to work).

So for my new project, my routes.rb now look like this:

ActionController::Routing::Routes.draw do |map|
   map.dash   '', :controller => "actions"

   map.connect_entity :person, :tag, :purpose

   map.connect  ':controller/:action', :action =>  
'index', :requirements => { :action => /[^\d]+/ }
   map.connect  ':controller/:id', :action => 'show', :requirements  
=> { :id => /[\d]+/ }
   map.connect  ':controller/:id/:action'
end

One problem with the scheme defined by Donald. It doesn't separate  
viewing an entity and editing it. So for now, I have edit still  
happening at person/1/edit, person/1 is showing, and person is the  
new form. Any thoughts on how to make the show/edit split happen more  
gracefully?

Also, it makes more sense to have the edit state be the postback than  
the show stage. Such that its the edit action that shares both  
showing the form and updating, not the show action.
--
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