Skip to content

Instantly share code, notes, and snippets.

View pindell-matt's full-sized avatar

Matt Pindell pindell-matt

View GitHub Profile
## 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.
@pindell-matt
pindell-matt / cfu_crud_in_sinatra.markdown
Last active March 23, 2016 04:17 — forked from rwarbelow/cfu_crud_in_sinatra.markdown
CRUD in Sinatra -- Check for Understanding
  1. Define CRUD

  2. CRUD is an acronym to remember the basic functionality: 'Create', 'Read', 'Update', and 'Delete'

  3. 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.

  4. '/elements' + GET - for viewing all elements.

  5. '/elements/:id' + GET - for viewing a specific element.

  6. '/elements/new' + GET - for viewing a form to create a new element.

  7. '/elements' + POST - for submitting a form to create a new element, redirects to list of all elements.

  8. '/elements/:id/edit' + GET - for viewing a form to edit an already-existing element.

  9. '/elements/:id' + PUT (PATCH) - for submitting a form that edits an already-existing element.

Introduction to Sinatra

1. What is the purpose of the server file (routing)?

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.)

2. How do you pass variables into the views?

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})

3. How can we interpolate ruby into a view (html)?