Skip to content

Instantly share code, notes, and snippets.

@serradura
Forked from fernandes/in_memory.rb
Created July 24, 2020 18:36
Show Gist options
  • Save serradura/4f900a6a44d399c86a47ecc077063c89 to your computer and use it in GitHub Desktop.
Save serradura/4f900a6a44d399c86a47ecc077063c89 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