I’m still trying to make restful desing click in my head. Yesterday I
asked about good
examples apps to learn from, and there don’t appear to be very many.
And most of the examples that do exist seem to be fairly strait forward
mappings to rest concepts… posts and comments and such.
So I’d like to see some more examples, and in particular I think it
would be fun to turn the “Depot” store app from AWDR into a more restful
example. For me it would be a nice example because fairly simple and
clean and it’s not quite clear to me how a restful desing would be
Two sets of questsion to get me started.
Does this seems like a useful thing to do? Would anyone learning
restful design out there like to see this, and for people who already
get it is the Depot app a good candidate?
And second does anyone have design tips that I should use to get
started? So far this is what I’ve done.
used the restful_authentication plugin to generate an authentication
used scaffold_resource to generate resources to model the store:
use the resources_controller plugin to simplify the controller
implementation for the apps resources.
right now these are what my routes look like:
map.resources :users, :sessions, :products
map.resources :carts do |cart|
map.resources :orders do |order|
So now I can browse and edit the model layer of my store, but the view
and controller layers are missing a lot and I’m not sure where to go
next. Whats the proper way to add the basic Depot style behavior ontop
of this structure. The features that I’m missing are:
- list of products with “Add to Cart” buttons next to each.
- shopping cart on each page showing what I’ve added.
- empty cart behavior
- checkout behavior that creates a new order
I know how to get all of this behavior by copying the Depot example from
the book and creating a StoreController, but it seems like that’s not
the most restful design. So please helpe point me in the right direction
and maybe I’ll be able to get a good example going.