Skip to content

Instantly share code, notes, and snippets.

@Aevin1387
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aevin1387/8b2cbfcf590834107f81 to your computer and use it in GitHub Desktop.
Save Aevin1387/8b2cbfcf590834107f81 to your computer and use it in GitHub Desktop.
class Company < ActiveRecord::Base
has_many :people
end
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
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