Last active
August 29, 2015 14:14
-
-
Save Aevin1387/8b2cbfcf590834107f81 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
class Company < ActiveRecord::Base | |
has_many :people | |
end |
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
class ExampleMigration < ActiveRecord::Migration | |
def change | |
create_table :companies do |t| | |
t.string :name | |
end | |
create_table :people do |t| | |
t.references :company, index: true | |
t.datetime :born_on | |
end | |
add_foreign_key :people, :companies | |
end | |
end |
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
class Person < ActiveRecord::Base | |
belongs_to :company | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment