Create Read Update Delete
2. 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 'somethings'
- See a list of all things
- GET 'somethings/thingid'
- See a specific thing
- GET 'somethings/new'
- See form to create new thing
- POST 'somethings'
- submit form to create new thing
- GET 'somethings/thingid/edit'
- See the form the edit a thing
- PUT 'somethings/thingid'
- submit form to edit a thing
- DELETE 'somethings/thingid'
- delete a thing
forms use POST by default. But POST is used to create new information. Because we are editing information and not creating new information we want to make a PUT request. set method_override: true
tells Sinatra to use Rack::MethodOverride middleware to allow use of PUT.
4. Explain the difference between value
and name
in this line: <input type='text' name='task[title]' value="<%= @task.title %>"/>
.
The name variable is what we will call the element when we PUT or POST it from the form. the value is what will show in the form when the page is first loaded by the client.
params are the information passed in POST or PUT requests, they are passed in the body of these requests from HTML forms or input.
Looks good Josh. Thanks