Skip to content

Instantly share code, notes, and snippets.

@joevandyk
Created March 21, 2014 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joevandyk/9691869 to your computer and use it in GitHub Desktop.
Save joevandyk/9691869 to your computer and use it in GitHub Desktop.
require 'sequel'
require 'active_record'
DB = Sequel.connect('postgres://localhost/tanga_dev')
puts DB[:users].count
ActiveRecord::Base.connection.instance_variable_set(:@connection, DB.synchronize{|c| c})
puts ActiveRecord::Base.connection.select_one('select count(*) from users')
# results in
10
/usr/local/stow/ruby-2.1.1-gh-2014.3.18/lib/ruby/gems/2.1.0/gems/activerecord-4.0.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:546:in `retrieve_connection': ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)
from /usr/local/stow/ruby-2.1.1-gh-2014.3.18/lib/ruby/gems/2.1.0/gems/activerecord-4.0.4/lib/active_record/connection_handling.rb:79:in `retrieve_connection'
from /usr/local/stow/ruby-2.1.1-gh-2014.3.18/lib/ruby/gems/2.1.0/gems/activerecord-4.0.4/lib/active_record/connection_handling.rb:53:in `connection'
from /tmp/t.rb:7:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment