• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Routes Controllers
 

Routes Controllers

on

  • 706 views

 

Statistics

Views

Total Views
706
Views on SlideShare
706
Embed Views
0

Actions

Likes
0
Downloads
10
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Routes Controllers Routes Controllers Presentation Transcript

    • ROUTES AND CONTROLLERSSaturday, March 5, 2011
    • 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
    • REST • Representational State Transfer (REST) • Architecture Pattern • Supports Distributed Hypermedia such as the World Wide Web • Roy Fielding, 2000Saturday, March 5, 2011
    • 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 between UI and data storageSaturday, March 5, 2011
    • 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
    • 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
    • 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
    • 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
    • DEFAULT REST Delete The delete action destroys a specific model Sample URL: http://localhost:3000/people/42 HTTP DELETESaturday, March 5, 2011
    • Saturday, March 5, 2011