REST - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

REST

Description:

Podcast Example. From Peepcode. restful_auth. Nested models ... and more! ActiveResource ... How to use it. Scaffold plugin. Success story from Scott Raymond ... – PowerPoint PPT presentation

Number of Views:123
Avg rating:3.0/5.0
Slides: 17
Provided by: jason350
Category:
Tags: rest

less

Transcript and Presenter's Notes

Title: REST


1
REST
REST in Rails and ActiveResource, too!
2
Agenda
  • What is REST?
  • Why REST?
  • Hows it fit into Rails?
  • Workshop
  • Things to watch out for

3
Whats REST?
  • Representational State Transfer
  • http//en.wikipedia.org/wiki/Representational_Stat
    e_Transfer

4
(No Transcript)
5
Why REST?
  • Clarifying, simplifying your architecture
  • Think web services
  • Its not SOAP
  • Its not XML-RPC
  • Its just HTTP
  • Curl, WireShark can be your friends
  • Even I can form HTTP requests on the command
    line! (maybe sometimes)

6
Why REST?
  • Separation of concerns
  • URIs identify resources
  • HTTP verb/method identifies operation

7
Why REST?
  • Default RailsGET /people/show/1
  • RESTfulGET /people/1

8
Why REST?
  • Default RailsPOST /people/delete/1
  • RESTfulDELETE /people/1

9
What does it mean to my Rails app?
  • Server side
  • Simply RESTful plugin
  • Now in Rails, as of 1.2ish?
  • Client side
  • ActiveResource (ARes)

10
Simply RESTful
  • Helps you organize.
  • Two (or three!) big tools
  • Routes
  • respond_to
  • (and scaffold_resource, too!)
  • Cheat sheet

11
Podcast Example
  • From Peepcode
  • restful_auth
  • Nested models
  • and more!

12
ActiveResource
  • Client consumption maps remote REST services
    into local objects
  • Just like what ActiveRecord does for databases
    and SQL!

13
Getting ActiveResource
  • 1.) Edge Rails
  • 2.) Get it yourselfsvn co http//dev.rubyonrail
    s.org/svn/rails/trunk/activeresource
    APP_ROOT/vendor/rails/activeresource
    RailsInitializer.run do config
    config.load_paths W( RAILS_ROOT/vendor/rail
    s/activeresource/lib )end

14
ActiveResource Examples
  • Person ActiveResourceStruct.new do person
    person.uri "http//api.myremote.com/people"
    person.credentials name gt "me", password
    gt "pwend
  • person Person.find(1)GET http//api.myremote.co
    m/people/1lt Bob XML, HTML, some
    representation
  • person.name "Jason" person.save!PUT
    http//api.myremote.com/people/1gt Jasonlt
    Location http//api.myremote.com/people/1

15
ContactsAPI
  • ActiveResource client lib example
  • http//contactsapi.com/docs/activeresource-client

16
Further Reading
  • Another UG Presentation
  • http//ryandaigle.com/articles/2007/3/14/rest-acti
    veresource
  • Code
  • Beast, a complete CRUD-based forum application
  • A CRUD Controller that you can inherit from
    instead of using a scaffold
  • Rick Olson Plugins
  • Rails Core Plugins
  • Ideas
  • An article that inspired the idea in Rails
  • Using cURL with REST Methods
  • Other REST Articles
  • Changes in Edge
  • How to use it
  • Scaffold plugin
  • Success story from Scott Raymond
  • Google cache of Scott Raymonds blog, with
    comments
  • Discussion about the Blinksale API
  • Lectures
  • Chris Abad on REST
Write a Comment
User Comments (0)
About PowerShow.com