Implement a 'mini' Rails application that implements associations.
For this project, I am required to:
Create a Rails API backend. Have at least three resources (three DB tables).
Create the following relationships:
- A Restaurant has many Pizzas through RestaurantPizza
- A Pizza has many Restaurants through RestaurantPizza
- A RestaurantPizza belongs to a Restaurant and belongs to * a Pizza
This link can be easily used to test the different routes/requests available to the API server. If you want to have the project in your development environment, proceed to set it up as outlined in the section that follows.
https://pizza-server-20v2.onrender.com
In order to use this repository, you need the following:
- Operating System (Windows 10+, Linux 3.8+, or MacOS X 10.7+)
- An account on Postman API Platform. CLICK HERE TO CREATE ONE
- RAM >= 4GB
- Free Space >= 2GB
- Fork and clone the repository.
- Ensure the ruby gems are setup in your machine
bundle install
- Perform any pending database migrations and seed data
rails db:migrate db:seed
- Make sure no other application is using PORT 3000 and run the application
rails s
- Using your preferred API testing platform (Postman, ThunderClient, etc), proceed to test the various routes available to the API. This will be your base URL:
http://localhost:3000
Add validations to the RestaurantPizza
model:
- must have a
price
between 1 and 30
Set up the following routes. Make sure to return JSON data in the format specified along with the appropriate HTTP verb. Also, ensure that errors are returned and handled appropriately. This includes and is not limited to necessary status codes.
GET /restaurants
GET /restaurants/:id
DELETE /restaurants/:id
GET /pizzas
POST /restaurant_pizzas
Project contributed to and maintained by: