- Define CRUD.
- Create, Read, Update, and Delete. This methodology gives full functionality for an object in any 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.
- /tasks GET - lets the user see all of the tasks that have been created (Read)
- /tasks/:id GET - lets the user see a single task and its contents (Read)
- /tasks/new GET - gives the user a form to create a new task (Create)
- /tasks POST - submits a new task to the database (Create)
- /tasks/:id/edit GET - gives the user a form to edit an existing task (Create)
- /tasks/:id PUT (PATCH) - submits edits/updates for an existing task (Update)
- /tasks/:id DELETE - lets the user delete a task from the database (Delete)
- Why do we use set method_override: true?
- It allows us to override the POST method in the edit form.
- Explain the difference between value and name in this line:
<input type='text' name='task[title]' value="<%= @task.title %>"/>
- Name will be the identifier when you want to access the data from params in the POST (a reference to the data when it is submitted. In the context of a "text" input type, value is the default value in the text-input field.
- What are params? Where do they come from?
- Params are a set of "variables" that are passed to the router if certain HTTP verbs are used (like POST or PUT). In Sinatra, params come into the router as a hash of symbols.