Skip to content

Instantly share code, notes, and snippets.

@thomasklemm
Last active August 29, 2015 14:00
Show Gist options
  • Save thomasklemm/11166379 to your computer and use it in GitHub Desktop.
Save thomasklemm/11166379 to your computer and use it in GitHub Desktop.
ActiveRecord without Rails, e.g. in a script
require 'active_record'
ActiveRecord::Base.establish_connection( adapter: 'sqlite3', database: ":memory:" )
ActiveRecord::Migration.verbose = false
ActiveRecord::Schema.define(version: 1) { create_table(:articles) { |t| t.string :title } }
class Article < ActiveRecord::Base; end
Article.create title: 'Quick brown fox'
Article.create title: 'Fast black dogs'
Article.create title: 'Swift green frogs'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment