Skip to content

Instantly share code, notes, and snippets.

@capitalsav
Created January 23, 2019 22:26
Show Gist options
  • Save capitalsav/c3f8bc604e2ed80b11ed645af199880f to your computer and use it in GitHub Desktop.
Save capitalsav/c3f8bc604e2ed80b11ed645af199880f to your computer and use it in GitHub Desktop.
Activerecord without rails example
require 'mysql2'
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => "mysql2",
:host => "localhost",
:username => "username",
:password => "password",
:database => "garage")
class Car < ActiveRecord::Base
end
car = Car.new
car.name = "Tesla"
car.model = "Model X P100D 4x4"
car.max_speed = 250
car.engine = "Electro"
car.save
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem 'activerecord'
gem 'mysql2'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment