- Define CRUD.
- Create
- Read
- Update
- Delete
- There are seven verb + path combinations that are necessary in a basic Sinatra app in order to provide full CRUD functionality. List each of the seven combinations, and explain what each is for.
- VERB: GET | PATH: /thing_all - Allows for reading of a database
- VERB: GET | PATH: /new_thing - Allows for rendering of the create form
- VERB: POST | PATH: /thing_all - Creates a new thing
- VERB: GET | PATH: /thing/id/edit - Renders a form for update to change the thing
- VERB: PUT/PATCH (POST) | PATH: /thing/id - Updates the thing with in the database
- VERB: DELETE (POST) | PATH: /thing/id - Deletes the thing with in the database
- VERB: GET | PATH: /thing/id - Reads one single thing
- Why do we use
set method_override: true
?
- Many clients only send GET / POST requests. So the standard is to use POSTs with a method override in the body when using different verbs.
- Explain the difference between
value
andname
in this line:<input type='text' name='task[title]' value="<%= @task.title %>"/>
.
name
is the identifier of the HTTP elementvalue
is used with in the input; In this case as the default text that populates the textarea
- What are
params
? Where do they come from?
params
are the parameters that are sent to server.- The parameters either come from the URL or the body of the request, GET and POST respectively