Skip to content

Commit

Permalink
update mod2 proj description to hint at route ordering and make forei…
Browse files Browse the repository at this point in the history
…gn key attributes be ints to align with postman tests
  • Loading branch information
juliet-e committed Jan 14, 2025
1 parent f5d9e5a commit 3586d63
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 775 deletions.
22 changes: 16 additions & 6 deletions module2/projects/little_shop/back_end_requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -610,26 +610,26 @@ This endpoint should:
"id": "86",
"type": "invoice",
"attributes": {
"customer_id": "17",
"merchant_id": "3",
"customer_id": 17,
"merchant_id": 3,
"status": "shipped"
}
},
{
"id": "186",
"type": "invoice",
"attributes": {
"customer_id": "39",
"merchant_id": "3",
"customer_id": 39,
"merchant_id": 3,
"status": "shipped"
}
},
{
"id": "318",
"type": "invoice",
"attributes": {
"customer_id": "67",
"merchant_id": "3",
"customer_id": 67,
"merchant_id": 3,
"status": "shipped"
}
}
Expand Down Expand Up @@ -663,6 +663,16 @@ Once you choose the group you are implementing, you will build the corresponding
* `GET /api/vi/merchants/find`, find a single merchant which matches a search term
* `GET /api/vi/merchants/find_all`, find all merchants which match a search term

<section class="call-to-action">
#### Route Ordering

Rails reads our routes top-to-bottom. When we get into creating non-RESTful routes, we run the risk of having Rails interpret a string in our routes as a dynamic variable. For example, if we have both of the routes below:
* `/api/v1/merchants/find`
* `/api/v1/merchants/:id`
There is a possibility that, depending on which route is defined first, the `find` string in the path can be incorrectly interpreted by Rails as the value of the dynamic `:id` segment. So, if you are working on these routes and find that your `find` request is ending up hitting a different controller action that what you expected, expermient with playing around with route ordering!

</section>

These endpoints will make use of query parameters as described below:
<section class="dropdown">
### 9. "Find One" endpoints
Expand Down
Loading

0 comments on commit 3586d63

Please sign in to comment.