Created
February 17, 2016 20:19
-
-
Save ksk5280/bf7e37834389aa082e43 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Describe one-to-one, one-to-many, and many-to-many database relationships | |
* one-to-one = a person has a SSN | |
* one-to-many => the US has many states, the states belong to one country, | |
* many-to-many => a child has multiple parents, the parent has many children. a person can attend many events | |
* Explain the difference between dev, test, and production environments in Rails | |
* In development Rails runs on local machine so you can see data | |
* Production mode is a public facing database | |
* The test mode is used in the tests and is wiped clean between test runs | |
* How do you create a Rails app from the command line with a postgres database? | |
* rails new appname --database=postgresql | |
* What files are created by typing rails g model Author first_name:text last_name:text? | |
* db/migrate/20160217165920_create_authors.rb | |
* app/models/author.rb | |
* test/models/author_test.rb | |
* test/fixtures/authors.yml | |
* What's the difference between typing rails g model ... and rails g migration ...? | |
* model creates model and migration and two test files | |
* migration only creates a migration. use this if only changing the migration | |
* Imagine that the items table has a category called quantity. | |
What command would you type if you wanted to get rid of the quantity attribute? | |
* rails g migration RemoveQuantityFromItems quantity:integer | |
* Imagine that you have a table students. | |
What is the ActiveRecord query that would return all students with the first name of Richard? | |
* Student.where(first_name: "Richard") | |
* How would you update the student record with ID 4 to have a new phone number of "101-222-3333"? | |
* Student.find(4).update(phone_number: "101-222-3333") | |
* Student.update(4, phone_number: "101-222-3333") | |
* student = Student.find(4) | |
student.phone_number = "101-222-3333" | |
student.save |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment