https://github.com/geekshubhamrajput/rails7-alpha2
This is rails 7 demo application
https://github.com/geekshubhamrajput/rails7-alpha2
Last synced: about 2 months ago
JSON representation
This is rails 7 demo application
- Host: GitHub
- URL: https://github.com/geekshubhamrajput/rails7-alpha2
- Owner: GeekShubhamRajput
- Created: 2021-09-22T12:25:59.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-09-22T12:27:23.000Z (over 3 years ago)
- Last Synced: 2025-02-07T03:41:49.049Z (3 months ago)
- Language: Ruby
- Size: 26.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Course and Tutor
#### Tasks
###### Given 2 models - Course & Tutor1. A course can have many tutors.
2. Tutor can teach one course only.###### Write:
1. Common POST API to create a course & its tutors
2. GET API to list all the courses along with their tutors## Steps are necessary to get the application up and running.
###### Ruby/rails version
ruby version 3.0.0
rails version 7.0.0.alpha2###### run bundle command
```
$ bundle install
```###### create and migrate database
```
$ rails db:create
$ rails db:migrate
```###### To run specs
```
$ rspec
```## API details
Run API by rails console
1. API to create a course & its tutors
```
HTTParty.post('http://localhost:3000/courses', query: {course: { title: "English1d6", details: "testung", tutors_attributes: [{ name: "Shubham12", email: "[email protected]"}]}})
```
2. GET API to list all the courses along with their tutors
```
response = HTTParty.get('http://localhost:3000/courses')
response.to_a
```