Define CRUD.
- Create - tells the server to make a new instance
- Read - asks the server for information
- Update - tells the server to change something in an existing instance
- Delete - tells the server to remove something
These four functions are necessary for a complete web application.
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 + /index --> view the home page and an overview of everything
- GET + /index/instance-id --> view the information on a particular instance
- GET + /index/new --> see the form to create a new instance
- POST + /index/instance-id --> create and then view the new instance created
- GET + /index/instance-id/edit --> see the form to edit an existing instance
- PUT + /index/instance-id --> edit and then view the existing instance that was edited
- DELETE + /index/instance-id --> delete an existing instance
**Why do we use set method_override: true
? **
We use this expression because the default verb for a form is POST, but convention requires us to sometimes use PUT or DELETE depending on the intentions of the user. As a result, we need to override the default verb in the form. In order to be allowed to perform this override, we need to use the expression to tell our application that such an override is permissible.
Explain the difference between value
and name
in this line: <input type='text' name='task[title]' value="<%= @task.title %>"/>
.
name
and value
form a key value pair such that task[name] = value
. Params is also a hash that contains task
but I'm not sure if task is in there as a key or value or what.
What are params
? Where do they come from?
Params are these things that seem to carry information from client to server in the form of a hash. I'm not really clear on how to access the information in them.
it should be only `POST + '/index' ==> create and then view the new instance created . Everything else looks good