Skip to content

Instantly share code, notes, and snippets.

@liaden
Created August 3, 2015 22:35
Show Gist options
  • Save liaden/225ce81a0c23672e0382 to your computer and use it in GitHub Desktop.
Save liaden/225ce81a0c23672e0382 to your computer and use it in GitHub Desktop.
active record without rails using sqlite in memory
require 'active_record'
require 'sqlite3'
ActiveRecord::Base.establish_connection(
adapter: 'sqlite3',
database: ':memory:'
)
ActiveRecord::Schema.define do
create_table :comments , force: true do |t|
t.string :name
end
create_table :posts , force: true do |t|
t.string :name
t.belongs_to :show, index: true
end
end
class Show < ActiveRecord::Base
end
puts Show.column_names
show = Show.new
puts show.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment