- Define CRUD.
- the conventional way to interact with a database: 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.
- GET + /tasks - show all of the tasks
- GET + /tasks/:id - show one task
- GET + /tasks/new - show form to create a new task
- POST + /tasks - create the new task
- GET + /tasks/:id/edit - see the update task form for a specific task
- PUT + /tasks/:id - update the task in the database
- DELETE + /tasks/:id - delete a specific task
- Why do we use
set method_override: true
?
- So we can PUT and DELETE since browsers only support POST and GET
- Explain the difference between
value
andname
in this line:<input type='text' name='task[title]' value="<%= @task.title %>"/>
.
- name is how we refer to that element (or its contents once we POST/PUT) while value is the text that will actually be in the input box when the user loads the page
- What are
params
? Where do they come from?
- params come from the POST request body. They are what is contained in the form inputs and text boxes.
looks good! for question #5, params can also come from the URL.