Skip to content

Instantly share code, notes, and snippets.

@jpawlyn
Last active December 22, 2015 13:59
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 jpawlyn/6482754 to your computer and use it in GitHub Desktop.
Save jpawlyn/6482754 to your computer and use it in GitHub Desktop.
ActiveRecord setup
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