Last active
December 22, 2015 13:59
-
-
Save jpawlyn/6482754 to your computer and use it in GitHub Desktop.
ActiveRecord setup
This file contains hidden or 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
require 'active_record' | |
ActiveRecord::Base.establish_connection( | |
adapter: 'sqlite3', | |
database: ':memory:' | |
) | |
ActiveRecord::Schema.define do | |
create_table :people do |table| | |
table.column :name, :string | |
table.column :age, :integer | |
table.timestamps | |
end | |
end | |
ActiveRecord::Schema.define do | |
create_table :pets do |table| | |
table.column :name, :string | |
table.column :furry, :boolean | |
table.belongs_to :person, null: false | |
table.timestamps | |
end | |
end | |
ActiveRecord::Schema.define do | |
create_table :addresses do |table| | |
table.column :street, :string | |
table.column :town, :string | |
table.column :city, :string | |
table.column :postcode, :string | |
table.timestamps | |
end | |
end | |
ActiveRecord::Schema.define do | |
create_table :posts do |table| | |
table.column :title, :string | |
table.column :body, :string | |
table.column :published, :boolean | |
table.timestamps | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment