Guest User

Untitled

a guest
Apr 17th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. require 'rubygems'
  2. require 'active_record'
  3.  
  4. class ActiveRecord::Base
  5. def self.remove_connection(klass=self)
  6. puts "DO NOT EVEN TRY"
  7. end
  8.  
  9. def self.clear_active_connection_name
  10. puts "Dont you get it ?"
  11. end
  12. end
  13.  
  14. class Con1 < ActiveRecord::Base
  15. self.establish_connection(
  16. :adapter => "mysql",
  17. :host => "localhost",
  18. :username => "root",
  19. :password => "",
  20. :database => "wtf_development"
  21. )
  22.  
  23. @@active_connections["fuck1"] = self.connection
  24.  
  25. def self.active_connection_name
  26. "fuck1"
  27. end
  28. end
  29.  
  30. class Con2 < ActiveRecord::Base
  31. self.establish_connection(
  32. :adapter => "mysql",
  33. :host => "localhost",
  34. :username => "root",
  35. :password => "",
  36. :database => "wtf_production"
  37. )
  38.  
  39. @@active_connections["fuck2"] = self.connection
  40.  
  41. def self.active_connection_name
  42. "fuck2"
  43. end
  44. end
  45.  
  46. puts "\nREAD FROM HERE\n"
  47. puts Con1.connection.object_id
  48. puts Con1.connection.select_value("SELECT COUNT(*) FROM items", "Con1 Count").to_i
  49.  
  50. puts Con2.connection.object_id
  51. puts Con2.connection.select_value("SELECT COUNT(*) FROM items", "Con2 Count").to_i
  52.  
  53.  
  54. # null:wtf lifo$ ruby wtf.rb
  55. # DO NOT EVEN TRY
  56. # Dont you get it ?
  57. # DO NOT EVEN TRY
  58. # Dont you get it ?
  59. #
  60. # READ FROM HERE
  61. # 9239040
  62. # 2
  63. # 9225070
  64. # 0
Add Comment
Please, Sign In to add comment