Skip to content

Instantly share code, notes, and snippets.

View jwashke's full-sized avatar

Josh Washke jwashke

View GitHub Profile

Introduction to Sinatra

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

The server file serves as the main point of contact between the client and the server. The server file takes in the http request from the client and routes the client to the proper page base on the verb and the path of the http request.

2. How do you pass variables into the views?

Instance variables are useable in the view when it is rendered. local variables you pass in using a key value hash erb(:index, locals => { :name_in_view => name_in_server }

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

Using ERB (Embedded RuBy) in the server call the erb method and tell it the view you want it to render.

@jwashke
jwashke / cfu_crud_in_sinatra.markdown
Last active March 23, 2016 04:23 — forked from rwarbelow/cfu_crud_in_sinatra.markdown
CRUD in Sinatra -- Check for Understanding
1. Define CRUD.

Create Read Update Delete

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 'somethings'
    • See a list of all things
  • GET 'somethings/thingid'
    • See a specific thing
  • GET 'somethings/new'
    • See form to create new thing
  • POST 'somethings'

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?

A primary key is the primary unique identifier of a table, a foreign key is the primary key of another table that serves as as the relationship between the two tables. A primary key is generally named id, a foreign key is named othertable_id whith the name of the table the foriegn key links to followed by id.

Write down one example of:

  • a one-to-one relationship.
    • Each car has one license plate and each license plate belongs to one car
  • a one-to-many relationship.
    • A School has many students but each student has only one school
  • a many-to-many relationship.

Setting Group Expectations

Group Member Names: Jared, Josh, Sunny

  1. When are group members available to work together? What hours can each group member work individually? Are there any personal time commitments that need to be discussed? Anytime. Josh needs to catch the last train but thats pretty late.

  2. How will group members communicate? How often will communication happen, and how will open lines of communication be maintained? Private slack channel