- Define CRUD.
CRUD stands for Create, Read, Update, and Delete which are associated with the verbs POST, GET, UPDATE, and DELETE in HTTP.
-
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.
-
READ '/tasks' - GET a view of all tasks from index.erb
-
READ '/tasks/:id' - GET a view of a specific task from show.erb
-
CREATE(pt1) 'tasks/new' - GET a form to create a new task in new.erb
-
CREATE '/tasks' - POST data to the server and redirect to '/tasks'
-
UPDATE(pt1) '/tasks' - GET a form to input date to update an existing task from edit.erb
-
UPDATE '/tasks/:id/edit' - PUT data to the server to update existing task information
-
DELETE '/tasks/:id' - DELETE existing information
-
Why do we use
set method_override: true
?
It allows you to use PUT and DELETE verbs in forms, since HTML requires the verb to look like POST.
- Explain the difference between
value
andname
in this line: `<input type='text' name='task[title]' value="<%= @task.title %>
Name defines what we will call the input(the title of our task), Value is what will be sent to the server, which in this case grabs the title of the individual task we are referring to.
-
What are
params
? Where do they come from?Params are pieces of data stored in a hash that comes from the instance variables defined in our object class. For example, in TaskManager params would include the title and description of our task, structured as a hash with a key of "task" pointing to those values.