Skip to content

Instantly share code, notes, and snippets.

@drew-t
Forked from rwarbelow/cfu_crud_in_sinatra.markdown
Last active March 23, 2016 04:26
Show Gist options
  • Save drew-t/72973578d0eb4524f78e to your computer and use it in GitHub Desktop.
Save drew-t/72973578d0eb4524f78e to your computer and use it in GitHub Desktop.
CRUD in Sinatra -- Check for Understanding
  1. Define CRUD. CRUD stands for Create, Read, Update, and Delete. These are the main functions that we can do to data.
  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 + /tasks: Read all tasks get + /tasks/:id: Read specific task get + /tasks/new: get form to fill out new task post + /tasks: Create a new task get + /tasks/:id/edit: See form to edit task info put + /tasks/:id: change task delete + /tasks/:id: delete a task
  3. Why do we use set method_override: true? Because we need to overwrite post with put and delete
  4. Explain the difference between value and name in this line: <input type='text' name='task[title]' value="<%= @task.title %>"/>. the name field denotes the name of the variable stored in the database, the value is the value stored in the particular name field.
  5. What are params? Where do they come from? That is what is sent by the forms
@Carmer
Copy link

Carmer commented Mar 23, 2016

Looks good. Just a note - the name field in the input of the form is what will defined the name of the key in the params hash, we write it so it represents something in a database, but it doesn't 'have to be' something in the database

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment