Skip to content

Instantly share code, notes, and snippets.

@rafadc
Last active February 2, 2016 20:52
Show Gist options
  • Save rafadc/3b8382114d9bd2e266d5 to your computer and use it in GitHub Desktop.
Save rafadc/3b8382114d9bd2e266d5 to your computer and use it in GitHub Desktop.
class CreatePeople < ActiveRecord::Migration
def change
create_table :people do |t|
t.string :name
t.timestamps null: false
end
end
end
class CreateAddresses < ActiveRecord::Migration
def change
create_table :addresses do |t|
t.string :street
t.belongs_to :person
t.timestamps null: false
end
end
end
class Address < ActiveRecord::Base
belongs_to :person
end
class Person < ActiveRecord::Base
has_many :address
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment