Skip to content

Instantly share code, notes, and snippets.

View JaredRoth's full-sized avatar

Jared Roth JaredRoth

View GitHub Profile

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 determines uniqueness of an entry in a table (generally, but not necessarily "id")
  • Foreign key references an entry in another table (by its primary key) ("foreignTableName_id")

Write down one example of:

  • Spouses/Couples, Person-SSN,
  • House-Occupants, School-Students
  • Albums-Artists, Students-Classes, Video Games-Players
@JaredRoth
JaredRoth / cfu_crud_in_sinatra.markdown
Last active March 23, 2016 04:08 — forked from rwarbelow/cfu_crud_in_sinatra.markdown
CRUD in Sinatra -- Check for Understanding
  1. Define CRUD.
  • The acronym for the basic actions carried out in web applications: Create, Read, Update, Delete
  1. 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 / GET - Displaying the collection
  • Read / GET - Displaying an item
  • Create / GET - Displaying the form for creating an item
  • Create / POST - Submitting the info from that form for creation
  • Update / GET - Displaying the form for changing an item
  • Update / PUT - Submitting the info from that form for changing
  • Delete / DELETE - Removing a designated item

Introduction to Sinatra

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

  • The server file specifies all routing requests and related operations.

2. How do you pass variables into the views?

  • As instance variables or using the locals hash

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