This is a very simple working backend API implementation using Ruby on Rails.
There are currently two models: Department and Employee. They have one-to-many (Department => Employee) relationship. They are related by department_id
field as Foreign Key of Employee model. The API is constructed in RESTful architecture.
Starts the server locally on port 3000.
Lists all available URI patterns, related HTTP verbs and corresponding controllers.
Runs all tests. To run specific tests in directories, run rails test:DIRECTORY_NAME
.
- Base endpoint (BASE):
localhost:3000
- Send GET request to BASE/employees or BASE/departments
- Send POST request to BASE/departments with raw body in JSON type and form
{ "department": { "department_name": NEW_DEPARTMENT_NAME } }
- Send POST request to BASE/employees with raw body in JSON type and form
{ "employee": { "employee_name": NEW_EMPLOYEE_NAME, "department_id": DEPARTMENT_ID } }
- Send DELETE request to BASE/employees/:id or BASE/departments/:id
- Send PUT request to BASE/employees/:id or BASE/departments/:id with the same body format for creation