Skip to content

Rails API implementation for internship task#1

Open
roman-mikhaylov wants to merge 2 commits into
uchiru:masterfrom
roman-mikhaylov:feature/rails-api
Open

Rails API implementation for internship task#1
roman-mikhaylov wants to merge 2 commits into
uchiru:masterfrom
roman-mikhaylov:feature/rails-api

Conversation

@roman-mikhaylov
Copy link
Copy Markdown

This pull request implements a Rails API according to the provided OpenAPI schema for managing schools, classes, and students.

Main changes:

  • Initialize a Rails 7 API application with PostgreSQL and Docker.
  • Implement the following endpoints:
    • GET /schools/{school_id}/classes – returns a list of classes in a school with students_count, returns 404 if the school is not found.
    • GET /schools/{school_id}/classes/{class_id}/students – returns a list of students in a specific class, with 404 responses for missing school or class.
    • POST /students – creates a student, returns the student JSON and an X-Auth-Token header for further deletion.
    • DELETE /students/{id} – deletes a student by ID using an Authorization: Bearer <token> header, with proper error responses for bad ID and missing/invalid token.
  • Add models and associations for School, SchoolClass, and Student with basic validations.
  • Add simple JSON rendering for successful and error responses.

How to run:

  • Start PostgreSQL in Docker (see README for example command).
  • Configure config/database.yml for the development environment.
  • Run bin/rails db:migrate.
  • Run the server with bin/rails s (or docker compose up if configured).
  • The API is available at http://127.0.0.1:3000.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant