Skip to content

Instantly share code, notes, and snippets.

Introduction to Sinatra

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

To act accordingingly to whatever is sent to the server.

2. How do you pass variables into the views?

through instance vairables or locals

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

@Jbern16
Jbern16 / cfu_crud_in_sinatra.markdown
Last active March 23, 2016 04:10 — 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. read: get, read: get, create: get, create: post, update: get, update: put, delete:, delete

  3. Why do we use set method_override: true? to set the form to put or delete instead of the default value of post. We override the verb.

  4. Explain the difference between value and name in this line: ``.

## 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?
We find a primary key as the main identifier of a table. Example: Teachers: TeacherId. A Foreign creates the relationship between tables.
Example: Teachers : course_id. The naming convention for these are the table they belong to + "_id"
#### Write down one example of:
* a `one-to-one `relationship.
each person has one toothbrush and one toothbrush has one person. This is modeled by combining both to a single table because they are
dependent of eachother