-
Define CRUD
-
CRUD is an acronym to remember the basic functionality: 'Create', 'Read', 'Update', and '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.
-
'/elements' + GET - for viewing all elements.
-
'/elements/:id' + GET - for viewing a specific element.
-
'/elements/new' + GET - for viewing a form to create a new element.
-
'/elements' + POST - for submitting a form to create a new element, redirects to list of all elements.
-
'/elements/:id/edit' + GET - for viewing a form to edit an already-existing element.
-
'/elements/:id' + PUT (PATCH) - for submitting a form that edits an already-existing element.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Models, Databases, Relationships in Rails | |
#### What is the difference between a primary key and a foreign key? | |
Primary Keys are uniq_ids for a table, foreign keys are primary keys featured on a separate table. | |
#### Where would we find a primary key? | |
On any table. | |
#### What would it be called by default? | |
Id. |
To provide different responses to different requests - taking the user to different pages / down different paths, to update or access different information, depending on the different requests (GET, POST, DELETE, etc.)
You can pass in instance variables (without explicitly passing them through the :locals hash) or local variables (in which case you must explicitly use the :locals hash ex: erb(:index, :locals => {:example => example})