Skip to content

Instantly share code, notes, and snippets.

@Thomascountz
Created February 16, 2022 08:41
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 Thomascountz/e36083a6a0c23e7c184cb5f4b3754917 to your computer and use it in GitHub Desktop.
Save Thomascountz/e36083a6a0c23e7c184cb5f4b3754917 to your computer and use it in GitHub Desktop.
In-memory ActiveRecord Test Bed
# active_record_testbed.rb
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'activerecord', require: 'active_record'
gem 'sqlite3', require: true
gem 'pry', require: true
end
ActiveRecord::Base.logger = Logger.new($stdout)
ActiveRecord::Base.establish_connection(
adapter: 'sqlite3',
database: ':memory:'
)
ActiveRecord::Schema.define do
create_table :users do |table|
table.integer :name, null: false
table.integer :account_id, null: false
end
end
class User < ActiveRecord::Base; end
binding.pry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment