Skip to content

Instantly share code, notes, and snippets.

View patrickwhardy's full-sized avatar

Patrick Hardy patrickwhardy

  • Slack
  • Boulder, CO
View GitHub Profile

Introduction to Sinatra

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

###The server file contains http verbs that dictate how a page is rendered, what logic is executed and what will be sent back to the client.

2. How do you pass variables into the views?

###Pass a var to the server file. The server file uses ERB to translate a designated file in the views dir.

@patrickwhardy
patrickwhardy / cfu_crud_in_sinatra.markdown
Last active March 23, 2016 04:16 — forked from rwarbelow/cfu_crud_in_sinatra.markdown
CRUD in Sinatra -- Check for Understanding
  1. Define CRUD. Create, read, update, destroy - this is the base functionality that all applications should provide
  2. 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. Get, /tasks - shows all tasks Get, /tasks/:id - shows one task Get, /tasks/new - shows form for task creation Post, /tasks - submits task content and creates object Get, /tasks/:id/edit - shows form to edit task info Put, /task/:id - submits changes to task info Delete, /task/:id - delets task
## Models, Databases, Relationships in Rails
#### What is the difference between a primary key and a foreign key? Where would we find a primary key? What would it be called by default? Where would we find a foreign key? What is the naming convention for a foreign key?
* Primary key lives on the one side of a one to many relationship. It is generally called tablename_id. The "many" object in the relationship holds on to a forieign key that uniqely identifies it's "one" association.
#### Write down one example of:
* a `one-to-one `relationship.
* Citizen to SSN
* One king to one kingdom
* a `one-to-many relationship`.
* One kingdom has many peasants