- 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.
get + "/something" renders and lists all, usually in a index view; get + "/something/:id" renders an item at a time; get + "/something/new" renders a viewable form for input; post + "/something" allows an input to be submitted, and then this is redirected to a index; get + "/something/:id/edit" allows for a form to be updated from an existing task put + "/something/:id" allows to submit an updated task; delete + "/something/:id" destroy a selected input.
- Why do we use
set method_override: true
?
*This is a sinatra method that allows the user to override an element/ process of there application. In order to allow the user to use override the user must use a _method in the link
- Explain the difference between
value
andname
in this line:<input type='text' name='task[title]' value="<%= @task.title %>"/>
.
*name is the id of the input field that is provided when we submit something, value is what is populated in the input field. It ends up creating a key/value pair example being task[name or title] = value(task.title)
- What are
params
? Where do they come from?
- params are hashes that come in from the url depending on the verb used. Example would be forms and inputs
we use method_override because http doesn't handle put and delete verbs - so we use the _method as the name of the hidden input field of a form so we can pass the verb through to the controller.