Skip to content

Instantly share code, notes, and snippets.

@jemmons
Last active December 15, 2015 09:48
Show Gist options
  • Save jemmons/5240635 to your computer and use it in GitHub Desktop.
Save jemmons/5240635 to your computer and use it in GitHub Desktop.
def self.with_memory_db
old_db_config = ActiveRecord::Base.connection_config
ActiveRecord::Base.establish_connection :adapter=>"sqlite3", :database=>":memory:"
yield(ActiveRecord::Base.connection) if block_given?
ensure
ActiveRecord::Base.establish_connection old_db_config
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment