Skip to content

Instantly share code, notes, and snippets.

@natevenn
Forked from rwarbelow/cfu_crud_in_sinatra.markdown
Last active February 3, 2016 00:44
Show Gist options
  • Save natevenn/5301f49964646701b1d3 to your computer and use it in GitHub Desktop.
Save natevenn/5301f49964646701b1d3 to your computer and use it in GitHub Desktop.
CRUD in Sinatra -- Check for Understanding
  1. Define CRUD.

    • these are functions that stands for 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 '/resources' - this retrieves the resources get '/resource/:id'- this retrieves the one resource get '/resources/new - this retrieves a form or some format for add resource post '/resources' - this creates the new resource get '/resources/:id/update - this retrieves a form that allows a specific resource to be modified or edited put '/resources' - this modifies or edits the specificed resource delete '/resources/:id' - this deletes the specified resource

  1. Why do we use set method_override: true? -The Get and post requests are universally recognizable but other methods like put and delete are not. So we us the method_override to make a put or delete request look like a post request.

  2. Explain the difference between value and name in this line: <input type='text' name='task[title]' value="<%= @task.title %>"/>. -(name)task[title] is getting set to (value)@task.title

  3. What are params? Where do they come from? -params is a hash of attributes and it comes from the information that is passed via a form

@rwarbelow
Copy link

  1. 👍
  2. almost all correct. for the retrieving an edit form, the path is /resources/:id/edit instead of /resources/:id/update
  3. 👍
  4. 👍
  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