Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JaredRoth/5750fa51d5ffd7b37488 to your computer and use it in GitHub Desktop.
Save JaredRoth/5750fa51d5ffd7b37488 to your computer and use it in GitHub Desktop.
CRUD in Sinatra -- Check for Understanding
  1. Define CRUD.
  • The acronym for the basic actions carried out in web applications: 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.
  • Read / GET - Displaying the collection
  • Read / GET - Displaying an item
  • Create / GET - Displaying the form for creating an item
  • Create / POST - Submitting the info from that form for creation
  • Update / GET - Displaying the form for changing an item
  • Update / PUT - Submitting the info from that form for changing
  • Delete / DELETE - Removing a designated item
  1. Why do we use set method_override: true?
  • HTTP doesn't actually know how to handle PUT or DELETE, so we need to override it's default behavior
  1. Explain the difference between value and name in this line: <input type='text' name='task[title]' value="<%= @task.title %>"/>.
  • Value is the title contents (In this example) of @task that are displayed in the form when the page is loaded
  • Name is the value passed when the form is submitted
  1. What are params? Where do they come from?
  • params is the hash of string values passed via HTML post when a form is submitted
@Carmer
Copy link

Carmer commented Mar 23, 2016

looks good

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