You can use ActiveRecord outside of a full Rails application in just a few steps. By adding the activerecord and sqlite3 gems to a Gemfile, calling ActiveRecord::Base.establish_connection, defining a schema with ActiveRecord::Schema.define, and creating a model class that inherits from ActiveRecord::Base, you get the full ORM experience in a plain Ruby script. This is useful for small scripts, scrapers, Sinatra APIs, or background workers where loading the entire Rails framework would be overkill.
Table of contents
STEP 1: The DependenciesSTEP 2: The ConnectionSTEP 3: The Database SchemaSTEP 4: The ModelSTEP 5: Using ItSort: