- Define CRUD.
- CRUD stands for "create, read, update, delete" and refers to the main functions for manipulating stored data
-
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 - to read all tasks
-
GET /tasks/:id - to read one task
-
GET /tasks/new - to view form for creating new task
-
POST /tasks - to submit form for creating new task
-
GET /tasks/:id/edit - to view form for updating task
-
PUT /tasks/:id - to submit form for updating task
-
DELETE /tasks/:id - to delete a task
-
Why do we use
set method_override: true
?
- Typically browsers cannot handle DELETE and PUT requests therefore we need to use POST and override.
- Explain the difference between
value
andname
in this line:<input type='text' name='task[title]' value="<%= @task.title %>"/>
.
- 'name' creates identifier for which the input's 'value' will be stored and by which the input's 'value' will be referred.
- What are
params
? Where do they come from?
- 'params' is a hash containing info (other than method and path) sent by a client to a server. In a GET request, they are part of the path. In a POST request, they are found in the body.