Skip to content

Instantly share code, notes, and snippets.

@hhoopes
Forked from rwarbelow/cfu_crud_in_sinatra.markdown
Last active February 2, 2016 23:07
Show Gist options
  • Save hhoopes/c11d25c07682249cf7ba to your computer and use it in GitHub Desktop.
Save hhoopes/c11d25c07682249cf7ba to your computer and use it in GitHub Desktop.
CRUD in Sinatra -- Check for Understanding
  1. Define CRUD. The 4 functions you need to be able to implement in a web app for a user to interact with data: CREATE READ UPDATE DELETE
  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. GET /collection : get the full set of data being stored GET /collection/1 : get an individual object that's being stored GET /collection/add : Gives the user the ability to add new information to the collection POST /collection : Submits the new data from the user GET /collection/1/edit : Gives the user the ability to update information about an item in the collection through a form PUT /collection/1 : Returns the updated information to the server through submitting the form DELETE /tasks/id/delete " Allows the user to remove data from the collection
  3. Why do we use set method_override: true? To access verbs that aren't implemented in most browsers, i.e., delete and put/patch. This lets us define these methods to update and delete data.
  4. Explain the difference between value and name in this line: <input type='text' name='task[title]' value="<%= @task.title %>"/>. Name identifies the data to be passed back to the server, value is what string is displayed to the user with HTML.
  5. What are params? Where do they come from? Params come from URLs or forms and store data in hash form to be sent to the server.
@rwarbelow
Copy link

  1. ✅ CRUD can also be used beyond web apps -- think of these as the basic functions for any stored data.

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