RESTful Routing Basics - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

RESTful Routing Basics

Description:

What can REST do for you? Fewer decisions to make ... Modify routes.rb. Modify the controller of the nested resource. add a before_filter ... – PowerPoint PPT presentation

Number of Views:24
Avg rating:3.0/5.0
Slides: 10
Provided by: andre155
Category:
Tags: basics | rb | restful | routing

less

Transcript and Presenter's Notes

Title: RESTful Routing Basics


1
RESTful Routing Basics
  • RoR Meetup, 1/18/2007
  • Andre Lewis

2
What Youll Learn
  • Getting started with RESTful resources in Rails
    1.2
  • Using scaffold_resource
  • How to nest resources

3
Motivation
  • Why care about REST?
  • What can REST do for you?

4
  • Fewer decisions to make
  • More easily understand others work, or your own
    older work
  • Nice URLs
  • Convenient named routes
  • XML/JS/JSON responses, easier

5
The REST Mindset
  • Think in terms of
  • Create ? GET /items/new
  • Retrieve ? GET /items/1
  • Update ? PUT /items/1
  • Delete ? PUT /items/1delete
  • Let the constraints imposed by CRUD guide your
    controller design

6
Lets code a Nested Resource
7
Review Nested Resources
  • Create the resource scaffolding and migrations
  • Set up relationships in models
  • Modify routes.rb
  • Modify the controller of the nested resource
  • add a before_filter
  • amend the _url calls in create and update
    actions
  • scope your Comment (nested class) finders to the
    Post (nestee class)
  • Modify the views
  • Provide a link to the nested resource

8
REST Learn More
  • My blog post at http//earthcode.com
  • DHH's REST keynote (get the slides too!)
  • http//www.loudthinking.com/lt-files/worldofresour
    ces.pdf
  • http//www.scribemedia.org/2006/07/09/dhh/
  • The 2nd edition of Pragmatic's Agile Web
    Development
  • Peepcode screencast and cheatsheet

Questions/Feedback?
  • what about optionally nested resources?
  • What about the new/edit request.get? pattern?
  • Is it bad to put additional methods on your
    RESTful controllers?

9
My Info
Write a Comment
User Comments (0)
About PowerShow.com