- Define CRUD. CRUD is an acronym that stands for create, read, update and delete. These four words correspond to the verbs in HTTP. In order to have full CRUD functionality within a Sinatral app, the app must be able to do all four of these things.
- 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. i. Read '/tasks' & GET shows view of all tasks from index.erb ii. Read '/tasks/:id' & GET shows view of a specific task from show.erb iii. Create 'tasks/new' & GET makes form to create a new task in new.erb iv. Create '/tasks' & POST sends data to the server and redirect to '/tasks' v. Update '/tasks' & GET makes a form to input and update an existing task from edit.erb vi. Update '/tasks/:id/edit' & PUT sends data to the server to update existing task information vii. Delete '/tasks/:id' & Delete deletes existing information
- Why do we use
set method_override: true
? This allows us to use PUT and DELETE as they are not usually avaiable in Sinatra - Explain the difference between
value
andname
in this line:<input type='text' name='task[title]' value="<%= @task.title %>"/>
. name is used to find the title value whereas value is finding the title for an instance of a task. - What are
params
? Where do they come from? params are the name and description of a task and they come from the create method within task_manager.rb
Forked from rwarbelow/cfu_crud_in_sinatra.markdown
Last active
February 3, 2016 20:21
-
-
Save damwhit/d26863795cf7c1280c11 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[:task][:title]
from the controller.params
hash can come from form data or through the URL.