Skip to content

ozandogrultan/ror-api-study

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ruby on Rails Simple Rest API

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.

Commands

rails server

Starts the server locally on port 3000.

rails routes

Lists all available URI patterns, related HTTP verbs and corresponding controllers.

rails test

Runs all tests. To run specific tests in directories, run rails test:DIRECTORY_NAME.

REST Methods

  • Base endpoint (BASE): localhost:3000

Get all employees/departments

  • Send GET request to BASE/employees or BASE/departments

Create new department

  • Send POST request to BASE/departments with raw body in JSON type and form { "department": { "department_name": NEW_DEPARTMENT_NAME } }

Create new employee

  • Send POST request to BASE/employees with raw body in JSON type and form { "employee": { "employee_name": NEW_EMPLOYEE_NAME, "department_id": DEPARTMENT_ID } }

Delete employees/departments

  • Send DELETE request to BASE/employees/:id or BASE/departments/:id

Update employees/departments

  • Send PUT request to BASE/employees/:id or BASE/departments/:id with the same body format for creation

Example views

All employees

Screen Shot 2019-05-21 at 15 06 57

All departments

Screen Shot 2019-05-21 at 15 15 08

New employee

Screen Shot 2019-05-21 at 15 16 17

Employee deleted

Screen Shot 2019-05-21 at 15 17 25

Updating department

Screen Shot 2019-05-21 at 15 18 46

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published