[uf-rest] REST opacity and URL schemes.

David Heinemeier Hansson david at loudthinking.com
Sat Apr 22 17:21:21 PDT 2006


> In the context of this particular list, I'm leaning towards using  
> semicolon to define "aspects" of a resource.  We'll see if we can  
> do this consistently enough that at least we don't confuse  
> ourselves...

The Simply Restful plugin is now capable of all these forms:

ActionController::Routing::Routes.draw do |map|
   map.resource :book
   #  GET    /books        --> { :controller => "books", :action =>  
"index"            }
   #  POST   /books        --> { :controller => "books", :action =>  
"create"           }
   #
   #  GET    /books/new    --> { :controller => "books", :action =>  
"new"              }
   #  GET    /books/4      --> { :controller => "books", :action =>  
"show",   :id => 4 }
   #  GET    /books/4;edit --> { :controller => "books", :action =>  
"edit",   :id => 4 }
   #  PUT    /books/4      --> { :controller => "books", :action =>  
"update", :id => 4 }
   #  DELETE /books/4      --> { :controller => "books", :action =>  
"delete", :id => 4 }
   #
   # Named routes:
   #   books_url          => "/books"
   #   book_url(:id => 5) => "/books/5"

   map.resource :book, :prefix => "/library/:library_id"
   #  GET    /library/3/books        --> { :controller =>  
"books", :action => "index",  :library_id => 3           }
   #  POST   /library/3/books        --> { :controller =>  
"books", :action => "create", :library_id => 3           }
   #
   #  GET    /library/3/books/new    --> { :controller =>  
"books", :action => "new",    :library_id => 3           }
   #  GET    /library/3/books/4      --> { :controller =>  
"books", :action => "show",   :library_id => 3, :id => 4 }
   #  GET    /library/3/books/4;edit --> { :controller =>  
"books", :action => "edit",   :library_id => 3, :id => 4 }
   #  PUT    /library/3/books/4      --> { :controller =>  
"books", :action => "update", :library_id => 3, :id => 4 }
   #  DELETE /library/3/books/4      --> { :controller =>  
"books", :action => "delete", :library_id => 3, :id => 4 }

   map.resource :book, :edit => true,
         :collection => { :edit => :get },
         :new        => { :new  => :get, :preview => :post },
         :member     => { :read => :get, :checkout => :post }
   #  GET    /books         --> { :controller => "books", :action =>  
"index"              }
   #  POST   /books         --> { :controller => "books", :action =>  
"create"             }
   #  GET    /books;edit    --> { :controller => "books", :action =>  
"edit"               }
   #
   #  GET    /books/new         --> { :controller => "books", :action  
=> "new"            }
   #  POST   /books/new;preview --> { :controller => "books", :action  
=> "preview"        }
   #
   #  GET    /books/4          --> { :controller => "books", :action  
=> "show",     :id => 4 }
   #  GET    /books/4;edit     --> { :controller => "books", :action  
=> "edit",     :id => 4 }
   #  GET    /books/4;read     --> { :controller => "books", :action  
=> "read",     :id => 4 }
   #  POST   /books/4;checkout --> { :controller => "books", :action  
=> "checkout", :id => 4 }
   #  PUT    /books/4          --> { :controller => "books", :action  
=> "update",   :id => 4 }
   #  DELETE /books/4          --> { :controller => "books", :action  
=> "delete",   :id => 4 }
end
--
David Heinemeier Hansson
http://www.37signals.com    -- Basecamp, Backpack, Writeboard, Tada
http://www.rubyonrails.com  -- Web-application framework
http://www.loudthinking.com -- Broadcasting Brain




More information about the microformats-rest mailing list