Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'active_record'
- class ActiveRecord::Base
- def self.remove_connection(klass=self)
- puts "DO NOT EVEN TRY"
- end
- def self.clear_active_connection_name
- puts "Dont you get it ?"
- end
- end
- class Con1 < ActiveRecord::Base
- self.establish_connection(
- :adapter => "mysql",
- :host => "localhost",
- :username => "root",
- :password => "",
- :database => "wtf_development"
- )
- @@active_connections["fuck1"] = self.connection
- def self.active_connection_name
- "fuck1"
- end
- end
- class Con2 < ActiveRecord::Base
- self.establish_connection(
- :adapter => "mysql",
- :host => "localhost",
- :username => "root",
- :password => "",
- :database => "wtf_production"
- )
- @@active_connections["fuck2"] = self.connection
- def self.active_connection_name
- "fuck2"
- end
- end
- puts "\nREAD FROM HERE\n"
- puts Con1.connection.object_id
- puts Con1.connection.select_value("SELECT COUNT(*) FROM items", "Con1 Count").to_i
- puts Con2.connection.object_id
- puts Con2.connection.select_value("SELECT COUNT(*) FROM items", "Con2 Count").to_i
- # null:wtf lifo$ ruby wtf.rb
- # DO NOT EVEN TRY
- # Dont you get it ?
- # DO NOT EVEN TRY
- # Dont you get it ?
- #
- # READ FROM HERE
- # 9239040
- # 2
- # 9225070
- # 0
Add Comment
Please, Sign In to add comment