Skip to content

Instantly share code, notes, and snippets.

@GustavoCaso
Created May 12, 2014 18:53
Show Gist options
  • Save GustavoCaso/bbc71c3eda42d52d38f3 to your computer and use it in GitHub Desktop.
Save GustavoCaso/bbc71c3eda42d52d38f3 to your computer and use it in GitHub Desktop.
Tealeaf Rails Rapid Prototyping with Ruby on Rails - Lesson 1 Quiz
1. The data is store in table which have an unique identifier, usually call primary id,
also it is posible to create relathionship between tables through this primary key.
2. SQL(Structured Query Language) is the language to acces the tables in our databases to
insert, extract, delete or update.
3. There are Data and Schema, schema is a way to represent the different tables in our DataBase
what type of data and the name of the columns. And Data show the data, inside the tables,
every Database has it own schema.
4. Primary Key
5. A foreign Key is an identifier inside of a table that refers to another table.
6. ActiveRecord connects the rich objects of an application to tables in a relational database management.
7. crazy_monkies
8. The froeign key will be in the issue model. The association will be Project has_many :issues and Issue belongs_to :project
9.
class Animal < ActiveRecord::Base
belongs_to :zoo
end
The schema show that table animals has the foreign_key zoo_id
zoo.animals
zoo.animals.all
zoo.animals.first
zoo.animals.last
zoo.animals.size
zoo.animals.each
zoo.animals.map
z = Zoo.create(name: "San Diego Zoo")
z.animals << Animal.create(name: "jumpster")
10. Strong Parameters
11. return the first animal
12. Animal.create(name: "Joe")
and the method that svae are save, save!, create, create!.
13. With a join table which have both foreign_keys
14. Has many through and Has and belongs to many. Has many through need a join table which allow us to save extra data inside the data
with habtm don't allow to save extra data because there are no join table inside the Database.
15.
g = Group.create
g.users.create
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment