- Define CRUD. Four main functions a user can use to manipulate data: Create, Read, Update, 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.
Using the Task Manager example:
- "/tasks", GET: shows all tasks
- "/tasks/:id", GET: shows one task
- "/tasks/new", GET: shows form to create a new task
- "/tasks", POST: creates a new task
- "/tasks/:id/edit", GET: shows form to edit a task
- "/tasks/:id", PUT: submit form to update existing task
- "/tasks/:id", DELETE: deletes a task
- Why do we use
set method_override: true
? To create put and delete methods - Explain the difference between
value
andname
in this line:<input type='text' name='task[title]' value="<%= @task.title %>"/>
. The value is what's put into the form, the name is a reference. - What are
params
? Where do they come from? params is a hash that contains each task as a key with a value of another hash that contains the task title and description. It comes from the create method in task_manager.rb
Forked from rwarbelow/cfu_crud_in_sinatra.markdown
Last active
February 3, 2016 20:15
-
-
Save ksk5280/c4f9d5330d7e4f2492d8 to your computer and use it in GitHub Desktop.
CRUD in Sinatra -- Check for Understanding
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
params[:name]
will give us the value