Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save deborahleehamel/6b54469fdb9bf79c4ba1 to your computer and use it in GitHub Desktop.

Select an option

Save deborahleehamel/6b54469fdb9bf79c4ba1 to your computer and use it in GitHub Desktop.
CRUD in Sinatra -- Check for Understanding

###Define CRUD.

C - Create R - Read U - Update D - Delete

###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/tasks
for reading database and rendering all items in the database

GET/tasks/:id
show a specific task :id

GET/tasks/new
show a form to enter a new task

POST/tasks
for creating a task when you click submit

GET/tasks/:id/edit
to see the form to edit an existing task

PUT/tasks/:id
to update existing task when you click submit

DELETE/tasks/:id
to delete a task from the list/database

###Why do we use set method_override: true?
allows us to override original form methods when using different verbs than usual

###Explain the difference between value and name in this line: <input type='text' name='task[title]' value="<%= @task.title %>"/>.
name is the identifier or reference for the HTTP element
value is the existing text or data input

###What are params? Where do they come from?
params are the data passed along as a hash key/value pairs
parameters are entered into our edit form and submitted to our server/database

@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