Skip to content

Instantly share code, notes, and snippets.

@georgebashi
Created January 25, 2014 02:55
Show Gist options
  • Save georgebashi/8611111 to your computer and use it in GitHub Desktop.
Save georgebashi/8611111 to your computer and use it in GitHub Desktop.
source "https://rubygems.org"
gem 'activerecord'
gem 'ar-octopus', require: 'octopus'
gem 'sqlite3'
#!/usr/bin/env ruby
require "octopus"
class User < ActiveRecord::Base
has_many :works
end
class Work < ActiveRecord::Base
end
ActiveRecord::Base.establish_connection YAML.load_file("config/database.yml")["development"]
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Base.connection.execute("create table if not exists user (id int); create table if not exists works (id int); create table if not exists user_works (user_id int, work_id int);")
a = User.using(:read_slave).first
a.works
b = User.last
b.save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment