Skip to content

Instantly share code, notes, and snippets.

@jraines
Created May 19, 2011 15:19
Show Gist options
  • Save jraines/981001 to your computer and use it in GitHub Desktop.
Save jraines/981001 to your computer and use it in GitHub Desktop.
Building Rich Apps - RailsConf 11 notes

###If I'm just sending JSON back and forth, why do I need Rails?

Rails is a rich HTTP abstraction, handles a lot for you

Read the HTTP spec

##ActionDispatch

###Middleware

Handles a lot for you -- Sessions, cookies, security, caching, MIMEs

JS templating engines

  • Handlebars.js

##JSON APIs

  • Nesting child resources are up to you
  • Naming keys is up to you
  • Error reporting formatting is up to you

##Rules for APIs

  • Root contains 1 or more keys
      {
        posts : {
          ...
        }
      }
  • No nested resources (by URL -- use params instead)
  • Nested objects should be the same
  • When using nested objects, use array of hashing containing objects, or array of ints with ids

Need a convention for bulk changes

//GET /posts/bulk?ids=1,2

{
  posts: [
    {id : 1 . . . },
    {id : 2 . . . }
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment