. Define CRUD.
An acrnym for Create, Read, Update, Delete, refering to database operations.
. 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.
-DELETE '/items/:id' -- used to delete a specific row from the database.
-PUT '/items/:id' -- used to update a row in the database.
-GET '/items/:id/edit' -- looks up the item to be updated.
-GET '/items/:id' -- used to read from a row in the database.
-POST '/items' -- used to add new information to the database.
-GET '/items' -- used to read all items in the database.
-GET '/items/new' -- part 1 of creating a new item, this combo does not interact with the database.
. Why do we use set method_override: true
?
To enable using a verb other than GET and POST.
. Explain the difference between value
and name
in this line: <input type='text' name='task[title]' value="<%= @task.title %>"/>
.
'value' will pre-fill the field with data, used in a CRUD sense when editing an existing row. 'name' refers to the name of the field.
. What are params
? Where do they come from?
'params' come from the the path in the request, they are treated as a hash.
Looks good!
For #5: params can come from either the path (URL) or form data submitted by the user.