0
ROUTES AND CONTROLLERSSaturday, March 5, 2011
ROUTES  • Abstract literal URLs from code  • The mapping between URLs and code, serves two purposes:    • Recognize URLs a...
REST  • Representational State Transfer (REST)  • Architecture Pattern  • Supports Distributed Hypermedia    such as the W...
CLIENT - SERVERSaturday, March 5, 2011
STATELESSSaturday, March 5, 2011
CACHESaturday, March 5, 2011
UNIFORM INTERFACESaturday, March 5, 2011
REST  •   client-server  •   stateless communication  •   uniform interface between components  •   separation of concerns...
RAILS REST HELPERS  in routes.rb  resources :people  $ rake routes  people GET	 	       /people(.:format)      	 	  {:acti...
DEFAULT REST  Index  The index action  provides a list of all the resources of a specific type  Sample URL: http://localhos...
DEFAULT REST  New  The new action displays the a form for creating a new object  Sample URL: http://localhost:3000/people/...
DEFAULT REST  Edit  The edit action displays the a form for modifying a specific object  Sample URL: http://localhost:3000/...
DEFAULT REST  Delete  The delete action destroys a specific model  Sample URL: http://localhost:3000/people/42  HTTP DELETE...
Saturday, March 5, 2011
Upcoming SlideShare
Loading in...5
×

Routes Controllers

666

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
666
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Routes Controllers"

  1. 1. ROUTES AND CONTROLLERSSaturday, March 5, 2011
  2. 2. ROUTES • Abstract literal URLs from code • The mapping between URLs and code, serves two purposes: • Recognize URLs and trigger a controller action • Generate URLs from names or objects, so you don’t have to hard code them in viewsSaturday, March 5, 2011
  3. 3. REST • Representational State Transfer (REST) • Architecture Pattern • Supports Distributed Hypermedia such as the World Wide Web • Roy Fielding, 2000Saturday, March 5, 2011
  4. 4. CLIENT - SERVERSaturday, March 5, 2011
  5. 5. STATELESSSaturday, March 5, 2011
  6. 6. CACHESaturday, March 5, 2011
  7. 7. UNIFORM INTERFACESaturday, March 5, 2011
  8. 8. REST • client-server • stateless communication • uniform interface between components • separation of concerns between UI and data storageSaturday, March 5, 2011
  9. 9. RAILS REST HELPERS in routes.rb resources :people $ rake routes people GET /people(.:format) {:action=>"index", :controller=>"people"} people POST /people(.:format) {:action=>"create", :controller=>"people"} new_person GET /people/new(.:format) {:action=>"new", :controller=>"people"} edit_person GET /people/:id/edit(.:format) {:action=>"edit", :controller=>"people"} person GET /people/:id(.:format) {:action=>"show", :controller=>"people"} person PUT /people/:id(.:format) {:action=>"update", :controller=>"people"} person DELETE /people/:id(.:format) {:action=>"destroy", :controller=>"people"}Saturday, March 5, 2011
  10. 10. DEFAULT REST Index The index action  provides a list of all the resources of a specific type Sample URL: http://localhost:3000/people HTTP GET Defualt web page: index.html Show The show action displays the details of a specific resources, by default identified by its ID Sample URL: http://localhost:3000/people/42 HTTP GET Defualt web page: show.htmlSaturday, March 5, 2011
  11. 11. DEFAULT REST New The new action displays the a form for creating a new object Sample URL: http://localhost:3000/people/new HTTP GET Defualt web page: new.html Create The create action accepts the form fields as parametrs to create a new model Sample URL: http://localhost:3000/people HTTP POST no corresponding web page (re-directs to show.html to display the newly created object)Saturday, March 5, 2011
  12. 12. DEFAULT REST Edit The edit action displays the a form for modifying a specific object Sample URL: http://localhost:3000/people/42/edit HTTP GET Defualt web page: edit.html Update The update action accepts form fields as parametrs to modify the attributes of a model Sample URL: http://localhost:3000/people/42 HTTP PUT no corresponding web page (re-directs to show.html to display the modified object)Saturday, March 5, 2011
  13. 13. DEFAULT REST Delete The delete action destroys a specific model Sample URL: http://localhost:3000/people/42 HTTP DELETESaturday, March 5, 2011
  14. 14. Saturday, March 5, 2011
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×