A Ruby on Rails application
View Demo
·
Report Bug
·
Request Feature
This is a food intake tracker API, which can be used to track the amount of food taken at a specified moment time. This food intake is managed by the administrator user.
- Ruby
- Ruby on Rails
- Bullet
- Rubocop
- PostgreSQL
- Users can create an account and sign in.
- Users can add measurements.
- Users can edit measurements.
- Users can delete measurements.
- Admin users can add intake.
- Admin users can edit intake.
- Admin users can delete intake.
These are the HTTP request methods used in this project:
| Method | Action |
|---|---|
GET |
This method is used to get a resource |
POST |
This method is used to create a resource or send data |
PATCH |
This method is used to update a resource |
DELETE |
This method is used to delete a resource |
The routes featured in this project:
| API routes(url) | Method | Description |
|---|---|---|
| /auth/signup | POST |
For user to create an account |
| /auth/signin | POST |
For a user to log in to an account |
| /api/v1/user/:id | PATCH |
For a user to edit his/her account |
| /api/v1/user/:id | DELETE |
For a user to delete his/her account |
| /api/v1/intakes | POST |
For a user to create an intake |
| /api/v1/intakes | GET |
For a user to get all intakes |
| /api/v1/intakes/:id | PATCH |
For a user to edit an intake |
| /api/v1/intakes/:id | DELETE |
For a user to delete an intake |
| /api/v1/intakes/:id/measurements | POST |
For a user to create measurement |
| /api/v1/intakes/:id/measurements | GET |
For a user to get all measurements |
| /api/v1/intakes/:id/measurements/:id | PATCH |
For a user to edit measurement |
| /api/v1/intakes/:id/measurements/:id | DELETE |
For a user to delete measurement |
Clone the repository to your local machine
$ git clone https://github.com/kobiyoyo/foodTrackerServer/.gitcd into the directory
$ bundle install --without productionNext,create & migrate the database:
$ rails db:create
$ rails db:migrate
Run the app in a local server:
$ rails server
Finally, run the test suite to verify that everything is working correctly:
$ rspec
You can then drop into rails console to explore the models
$ cd rails c- For a user to sign up:
http://localhost:3000/auth/signupPOST
{
"username": "daniel",
"email": "adamadan@gmail.com",
"password": "123dan",
"role": "client"
}
- For a user to sign in:
http://localhost:3000/auth/signinPOST
{
“auth”: {
"email": "adamadan@gmail.com",
"password": "123dan"
}
}
- For a user to edit his/her account:
http://localhost:3000/api/v1/user/:idPATCH
Sign into the user account and proceed to edit
Headers - Authorization `token`
- For a user to delete his/her account:
http://localhost:3000/api/v1/user/:idDELETE
Sign into the user account and proceed to delete
Headers - Authorization `token`
- For a user to create an intake:
http://localhost:3000/api/v1/intakesPOST
Sign into the user account
Headers - Authorization `token`
{
"title":"Oil"
}
- For a user to update an intake:
http://localhost:3000/api/v1/intakes/:idPATCH
Sign into the user account
Headers - Authorization `token`
{
"title": "Black is gold"
}
- For a user to get an intake:
http://localhost:3000/api/v1/intakes/:idGET
Sign into the user account
Headers - Authorization `token`
- For a user to get all intakes:
http://localhost:3000/api/v1/intakesGET
Sign into the user account
Headers - Authorization `token`
- For a user to delete an intake:
http://localhost:3000/api/v1/intakes/:idDELETE
Sign into the user account
Headers - Authorization `token`
- For a user to create measurement:
http://localhost:3000/api/v1/intakes/:id/measurementsPOST
Sign into the user account
Headers - Authorization `token`
{
"units":32
}
- For a user to update measurement:
http://localhost:3000/api/v1/intakes/:id/measurements/:idPATCH
Sign into the user account
Headers - Authorization `token`
{
"units": 324
}
- For a user to get measurement:
http://localhost:3000/api/v1/intakes/:id/measurements/:idGET
Sign into the user account
Headers - Authorization `token`
- For a user to get all measurements:
http://localhost:3000/api/v1/intakes/:id/measurements/GET
Sign into the user account
Headers - Authorization `token`
- For a user to delete an measurement:
http://localhost:3000/api/v1/intakes/:id/measurements/:idDELETE
Sign into the user account
Headers - Authorization `token`
Adama Chubiyojo Desmond
- Fork it (https://github.com/kobiyoyo/foodTrackerServer/fork)
- Create your feature branch (git checkout -b feature/[choose-a-name])
- Commit your changes (git commit -am 'what this commit will fix/add')
- Push to the branch (git push origin feature/[chosen-name])
- Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details