Skip to content

mdluo/todos-rails

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Todos

Todolist App for Ruby on Rails

Live demo

http://todos.nsmss.com/

Requirement

  • Git
  • Ruby
  • Rails

Deployment

Clone this repository:
git clone https://github.com/mdluo/todos.git
And go into the directory:
cd todos
Install bundle:
bundle install
Then run the migration:
rake db:migrate
One more thing, start the server:
rails server

API Document

Session name:

_todos_session

The session must included in the header of every requests.

Get all todos for current user:

GET 'http://host/todos/all'

Response JSON data sample:

[{"id":1,"task":"Task Title 01","completed":true},{"id":2,"task":"Task Title 2","completed":false}]
Create a new todo for current user:

POST 'http://host/todos/create'

New todo request JSON data sample:

{"task":"New Todo Title"}

New todo response JSON data sample:

{"id":1,"task":"New Todo Title","completed":false}
Update the status of a todo:

POST 'http://host/todos/update'

Update todo request JSON data sample:

{"id":1}

Update todo response JSON data sample:

{"id":1,"task":"New Todo Title","completed":true}
Delete a todo:

POST 'http://host/todos/delete'

Delete todo request JSON data sample:

{"id":1}

Delete todo response JSON data sample:

{"id":1,"task":"New Todo Title","completed":true}
Clear completed todos:

POST 'http://host/todos/delete'

Request JSON data:

{"id":-1}

Response JSON data sample (Return todos have not been marked as completed):

[{"id":1,"task":"Task Title 01","completed":false},{"id":2,"task":"Task Title 2","completed":false}]