Skip to content

Instantly share code, notes, and snippets.

@robbiejaeger
Forked from Carmer/crud.markdown
Last active May 11, 2016 02:44
Show Gist options
  • Save robbiejaeger/655ea8b644a64606db3eeaa086fafce6 to your computer and use it in GitHub Desktop.
Save robbiejaeger/655ea8b644a64606db3eeaa086fafce6 to your computer and use it in GitHub Desktop.
  1. Define CRUD.
  • Create, Read, Update, and Delete. This methodology gives full functionality for an object in any web application.
  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.
  • /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)
  1. Why do we use set method_override: true?
  • It allows us to override the POST method in the edit form.
  1. 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.
  1. 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment