1. Define CRUD.
- 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/index.rb: Listing all instances
- GET/show.rb: Shows one instance
- GET/new.rb: Creates ability for new instance
- POST/index.rb: Creates and saves a new instance
- GET(update)/new.rb: Update existing instance
- PUT/index.rb: Updates and saves edited instance
- DELETE/index.rb: Deletes existing instance
3. Why do we use set method_override: true
?
- Because HTML does not recognize some verbs such as Put/Delete so we must override defaults with our own methods
4. Explain the difference between value
and name
in this line: <input type='text' name='task[title]' value="<%= @task.title %>"/>
.
- value is what is displayed and name is the key to reference the value
5. What are params
? Where do they come from?
- params are endpoints that come from a get request. They are in the form of a ?key=value.
GET '/tasks'
orPUT '/tasks/:id'
params[:task]
'/tasks/:id/edit'
,:id
would be a dynamic parameter that we can access usingparams[:id]