Skip to content

Instantly share code, notes, and snippets.

@fernandes
Created July 23, 2020 00:00
Show Gist options
  • Save fernandes/3c7a074f0de92e8965bc32d972a56121 to your computer and use it in GitHub Desktop.
Save fernandes/3c7a074f0de92e8965bc32d972a56121 to your computer and use it in GitHub Desktop.
AR in memory
require "active_record"
require "sqlite3"
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:host => "localhost",
:database => ':memory:'
)
ActiveRecord::Schema.define do
create_table :posts do |t|
t.column :title, :string
end
end
class Post < ActiveRecord::Base
end
Post.create!(title: 'foo')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment