labs/hw for day 3

master
Matt Huntington 7 years ago
parent 241df4573c
commit 01ac8b796c

@ -23,5 +23,4 @@
1. Morning Lecture: [Nested Models](day3/instructor_notes/Nested_Models.md) 1. Morning Lecture: [Nested Models](day3/instructor_notes/Nested_Models.md)
1. Morning Lab: Implement Find for Both `/people/:id` and `/locations/:id` with Nested Models 1. Morning Lab: Implement Find for Both `/people/:id` and `/locations/:id` with Nested Models
1. Afternoon Lab (no lecture): Implement a Many-to-Many Relationship with a `Companies` Model 1. Afternoon Lab (no lecture): Implement a Many-to-Many Relationship with a `Companies` Model
- use a `jobs` intermediary table
1. Homework: Finish Lab 1. Homework: Finish Lab

@ -0,0 +1,3 @@
# Homework
Finish all labs from today and yesterday

@ -0,0 +1,3 @@
# Lab
Implement a Many-to-Many Relationship with a `Companies` Model (see [yesterday's morning lab](../../day2/student_labs/morning.md) for details on how the model should be structured). Use a `jobs` intermediary table.

@ -0,0 +1,40 @@
# Lab
Implement a show route for our people model (`/people/:id`) which will return to the client JSON representing the requested row in the `people` table along with a nested `home` attribute which will be the selected person's related location:
```JSON
{
"id":4,
"name":"Bob",
"age":25,
"home": {
"id":2,
"street": "123 Fake Street",
"city": "Aurora",
"state": "NY"
}
}
```
Do the same for locations (`/locations/:id`), but include a nested `inhabitants` attribute, which will be an array, containing objects representing the rows in the `people` table related to the selected location:
```JSON
{
"id":2,
"street": "123 Fake Street",
"city": "Aurora",
"state": "NY",
"inhabitants":[
{
"id":4,
"name":"Bob",
"age":25
},
{
"id":7,
"name":"Sally",
"age":74
},
]
}
```
Loading…
Cancel
Save