Skip to content

jimmypocock/rails-swift-angular

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

== README

DEPENDENCIES

  • xCode 6+
  • PostgreSQL
  • Ruby 1.9+
  • Yeoman & angular-generator

To set up API:

  • git clone <URL>
  • cd json-test-app/json-test-api
  • bundle install
  • rake db:create && rake db:migrate
  • rails s

Example of User Row

{
  first_name: "Bobby",
  last_name:  "Tables",
  bio: "Causes all kinds of problems",
  phone: "111-111-1111",
  email: "droptables@gmail.com"
}

Routes

    users   GET    /users(.:format)          users#index
            POST   /users(.:format)          users#create
 new_user   GET    /users/new(.:format)      users#new
edit_user   GET    /users/:id/edit(.:format) users#edit
     user   GET    /users/:id(.:format)      users#show
            PATCH  /users/:id(.:format)      users#update
            PUT    /users/:id(.:format)      users#update
            DELETE /users/:id(.:format)      users#destroy

Index: Get All Users

GET /users

curl -s -H "Accept: application/json"  \
        -H "Content-Type: application/json"  \
        -X GET http://localhost:3000/users \
        | python -mjson.tool

Show: Get One User

GET /users/:id

curl -s -H "Accept: application/json"  \
        -H "Content-Type: application/json"  \
        -X GET http://localhost:3000/users/:id \
        | python -mjson.tool

Create: Add a New User

POST /users

curl -s -H "Accept: application/json"  \
        -H "Content-Type: application/json"  \
        -X POST http://localhost:3000/users \
        -d '{"user":{"first_name":"Bobby","last_name":"Tables","bio":"Causes all kinds of problems","phone": "111-111-1111","email": "droptables@gmail.com"}}' \
        | python -mjson.tool

Update: Edit User Info

PUT /users/:id

curl -s -H "Accept: application/json"  \
        -H "Content-Type: application/json"  \
        -X PUT http://localhost:3000/users/:id \
        -d '{"user":{"first_name":"Robert","last_name":"Tables","bio":"Such a sweet boy","phone": "222-222-2222","email": "droptablizzies@gmail.com"}}' \
        | python -mjson.tool

Delete: Remove User

DELETE /users

curl -s -H "Accept: application/json"  \
        -H "Content-Type: application/json"  \
        -X DELETE http://localhost:3000/users/11 \
        | python -mjson.tool

About

This is a sample project that utilizes a RESTful API in Rails to speak to an Angular front-end app and a mobile app in Swift.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published