Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save amaxwellblair/ae1a0c2f2a69b536c771 to your computer and use it in GitHub Desktop.
Save amaxwellblair/ae1a0c2f2a69b536c771 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.
  2. VERB: GET | PATH: /thing_all - Allows for reading of a database
  3. VERB: GET | PATH: /new_thing - Allows for rendering of the create form
  4. VERB: POST | PATH: /thing_all - Creates a new thing
  5. VERB: GET | PATH: /thing/id/edit - Renders a form for update to change the thing
  6. VERB: PUT/PATCH (POST) | PATH: /thing/id - Updates the thing with in the database
  7. VERB: DELETE (POST) | PATH: /thing/id - Deletes the thing with in the database
  8. VERB: GET | PATH: /thing/id - Reads one single thing
  9. Why do we use set method_override: true?
  • Many clients only send GET / POST requests. So the standard is to use POSTs with a method override in the body when using different verbs.
  1. Explain the difference between value and name in this line: <input type='text' name='task[title]' value="<%= @task.title %>"/>.
  • name is the identifier of the HTTP element
  • value is used with in the input; In this case as the default text that populates the textarea
  1. What are params? Where do they come from?
  • params are the parameters that are sent to server.
  • The parameters either come from the URL or the body of the request, GET and POST respectively
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment