Skip to content

Instantly share code, notes, and snippets.

@rwarbelow
Created December 1, 2015 18:00
Show Gist options
  • Save rwarbelow/62813b91091455a1f3d3 to your computer and use it in GitHub Desktop.
Save rwarbelow/62813b91091455a1f3d3 to your computer and use it in GitHub Desktop.
CRUD in Sinatra -- Check for Understanding
  1. Define CRUD.
  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.
  3. Why do we use set method_override: true?
  4. Explain the difference between value and name in this line: <input type='text' name='task[title]' value="<%= @task.title %>"/>.
  5. What are params? Where do they come from?
@thePaulista
Copy link

  1. create-read-update-delete
  2. (a) get + "/something" renders and lists all, usually, on index view;
    (b) get + "/something/:id" renders an item at a time;
    (c) get + "/something/new" renders a viewable form for input;
    (d) post + "/something" allows an input to be submitted, and this is redirected to index view;
    (e) get + "/something/:id/edit" allows for a viewable form to be inputted to be editted;
    (f) put + "/something/:id" allows the above form to be submitted to be filed;
    (j) delete + "/something/:id" allows to destroy a previously input.
  3. this gives greater flexibility to use methods not available otherwise, like the hidden _methods. this allows us to set new values to post, like delete and put.
  4. a key/value pair. name is the id to item that will get modified, and the value will be what it will be replaced by.
  5. params are like hash pair, and they can be from a query or url path.

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