- Request-response cycle
- APIs
- Active Record
- Rack
- Sinatra
- Routes
- HTTP methods
- Params
- Strong params
- Dynamic routing
- POST/PATCH/DELETE requests
- Using React to send server requests
"Rack is the underlying technology behind nearly all of the web frameworks in the Ruby world." - Thoughtbot
HTTP Verb | Endpoint | Action |
---|---|---|
GET | /starships | Index |
GET | /starships/:id | Show |
POST | /starships | Create |
PATCH | /starships/:id | Update |
DELETE | /starships/:id | Destroy |
- To follow along with today's lecture, we will be working in 2 different repo's and terminals.
- CD into 'demo' and start the server by running
bundle exec rake server
. The routes will be defined inStarshipController
. - Then open a new terminal, CD back into the root directory and then cd into
demo react
and runnpm start
to start the React server. - Today we will communicate via a very simple React project to make requests to our API and receive responses that will be used in the application.
- For this exercise, cd into both
exercise
andexercise-react
in two separate terminals. - In
exercise-react
, runnpm start
to run the React server. - We will be using the
PizzasContainer
to complete the full CRUD cycle of this application. Do not worry about building other components. We will keep this application really simple and focus on the requests sent from React to our API. - Create a show route that will request details for one pizza with the given id. First create a request from the frontend, and then write the response for the request on the backend.
- Create an event handler for an edit form that will send a PATCH request to the backend.
- Create an event handler that will invoke upon a delete button click and send a request to the backend to delete a pizza with the given id.