Last active
October 27, 2015 18:47
-
-
Save rossedfort/f994062e248e26cf2590 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
one-to-one: Username and password | |
one-to-many: People and mailing address | |
People and pets | |
User and instagram photo | |
many-to-many: Teachers and mod_2 students | |
Hashtags and tweets | |
A test environment database can be set up to flush after every run, making it easier to keep track of what's in your db and what you are testing on. | |
A development environment database usually holds enough data to make sure your app is working as it should. It's usually fake data in the correct format. | |
-These can be dropped/deleted | |
A Production database is where actual users' information ends up. NEVER drop this database. It should only be populated with actual user data. | |
`rails new appname --database=postgresql`or `rails new appname -d postgresql` | |
`rails g model Model` creates a model for us that is named correctly and has a class within it with the proper inheritance, if you specify field names it creates a migration as well. | |
It makes it easy to set up the structure of your database. | |
`rails g model...` creates a model along with a migration file. `rails g migration...` just creates the migration file, and you would need | |
to do a `touch app/models/...` to make the model. | |
`rails g migration RemoveQuantityFromItems quantity:integer` | |
`students.where(first_name: 'richard')` | |
`students = Students.find(4)` | |
`student.update(phone_number: '101-222-3333')` = `student.update(4, phone_number: "92834092134") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment