Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save brantwellman/2027ddf9b5d69d98a1ac to your computer and use it in GitHub Desktop.
Save brantwellman/2027ddf9b5d69d98a1ac 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?
@brantwellman
Copy link
Author

  1. Create, Read, Update, Delete. Basic functions how to handle data in a Web Application
  2. 1 - /users - Get => View all users, 2 - /users/:id - GET => View one specific user 3 - /users/new - GET => View form to create a user 4 - /users - POST => Click submit to create new user 5 - /users/:id/edit - GET => See form to update existing user 6 - /users/:id - PUT => Click update to edit a user 7 - /users/:id - DELETE => Click to delete a user
  3. This allowed us to deal with the fact that browsers only recognize GET and POST when we also need to PUT an DELETE
  4. name is the "value" that the server is looking for. Value is the value(?) that is getting displayed(??)
  5. Params are the data that are being submitted from the form

@rwarbelow
Copy link

looks good! for #4, "name" could be explained as being the key of the params hash. for #5, params can also come from the URL.

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