Skip to content

Instantly share code, notes, and snippets.

@ToniRib
Forked from rwarbelow/cfu_crud_in_sinatra.markdown
Last active December 2, 2015 15:44
Show Gist options
  • Save ToniRib/7bf590520df2a6041c9c to your computer and use it in GitHub Desktop.
Save ToniRib/7bf590520df2a6041c9c to your computer and use it in GitHub Desktop.
CRUD in Sinatra -- Check for Understanding
  1. Define CRUD.
  • the conventional way to interact with a database: create, read, update, delete
  1. 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 - show all of the tasks
  • GET + /tasks/:id - show one task
  • GET + /tasks/new - show form to create a new task
  • POST + /tasks - create the new task
  • GET + /tasks/:id/edit - see the update task form for a specific task
  • PUT + /tasks/:id - update the task in the database
  • DELETE + /tasks/:id - delete a specific task
  1. Why do we use set method_override: true?
  • So we can PUT and DELETE since browsers only support POST and GET
  1. Explain the difference between value and name in this line: <input type='text' name='task[title]' value="<%= @task.title %>"/>.
  • name is how we refer to that element (or its contents once we POST/PUT) while value is the text that will actually be in the input box when the user loads the page
  1. What are params? Where do they come from?
  • params come from the POST request body. They are what is contained in the form inputs and text boxes.
@rwarbelow
Copy link

looks good! for question #5, params can also come from the URL.

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