Created
January 23, 2019 22:26
-
-
Save capitalsav/c3f8bc604e2ed80b11ed645af199880f to your computer and use it in GitHub Desktop.
Activerecord without rails example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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