Created
August 3, 2015 22:35
-
-
Save liaden/225ce81a0c23672e0382 to your computer and use it in GitHub Desktop.
active record without rails using sqlite in memory
This file contains 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' | |
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