Skip to content

Instantly share code, notes, and snippets.

View marinacor1's full-sized avatar

Marina Corona marinacor1

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 is the unique identifier within a table. Foreign key is the unique identifier of another table that has a relationship with the table.
By default it is the ID. A foreign key will be in the other table and will have a name that starts with the other table name (ex. students) and id.
So an example would be student_id.
#### Write down one example of:
* a `one-to-one `relationship. Person to sandwich. Bicycle to owner. A business to CEO.
@marinacor1
marinacor1 / cfu_crud_in_sinatra.markdown
Last active March 23, 2016 04:12 — 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 -retrieves info that comes in request POST - creates a new piece of information from the request PUT - updates specific information that is in the request

Introduction to Sinatra

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

It includes the HTTP verbs and determines what the server will do (i.e. what verb and path, like POST '/')

2. How do you pass variables into the views?

You can use a hash like :locals {:number => number}

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

We can use <% = ruby thing you want to show %>