Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save adamhundley/edbbd70ddc8736d3eabf to your computer and use it in GitHub Desktop.
Save adamhundley/edbbd70ddc8736d3eabf to your computer and use it in GitHub Desktop.
CRUD in Sinatra -- Check for Understanding
  1. Define CRUD.
  • 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 /all - shows everything created
  • GET /all/specific - shows a specific thing created
  • GET /all/new - gives form to create something new
  • POST /all - creates something new
  • GET /all/specific/edit - shows something that has already been created but needs to be changed
  • PUT /all/sepcific - makes changes
  • DELETE /all/specific - deletes
  1. Why do we use set method_override: true? -This allows us to override the standard post method when we need to make a PUT or DELETE request using _method
  2. Explain the difference between value and name in this line: <input type='text' name='task[title]' value="<%= @task.title %>"/>.
  • name is assigning the param and value is filling in the form
  1. What are params? Where do they come from?
  • params are key value pairs that come in from a post request or from the end of a url path
@rwarbelow
Copy link

  1. ๐Ÿ‘
  2. ๐Ÿ‘
  3. ๐Ÿ‘
  4. ๐Ÿ‘
  5. Mostly correct ๐Ÿ˜„ The params can come from the middle of the path if the dynamic parameter is there. For example: /tasks/:id/edit -- :id is the dynamic parameter.

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