Guest User

Untitled

a guest
Jan 12th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. Direct connection to secondary database not working
  2. class SupportBase < ActiveRecord::Base
  3.  
  4. configurations = { :adapter => 'mysql',
  5. :encoding => 'utf8',
  6. :reconnect => 'true',
  7. :database => 'xxxxxx',
  8. :username => 'xxxxxx',
  9. :password => 'xxxxxx',
  10. :host => 'xxxxxx',
  11. :port => 'xxxxx'
  12. }
  13.  
  14. self.abstract_class = true #important!
  15.  
  16. establish_connection configurations["deals_qa"]
  17.  
  18. set_table_name = 'members'
  19.  
  20. def self.get_test_name(id)
  21. if id == 0
  22. return ''
  23. else
  24. if SupportBase.connected?
  25. conn = SupportBase::connection
  26. query = "SELECT * FROM members where id = '#{id}'"
  27. #tst = connection.select_all(query)
  28. tst = conn.select_values(query)
  29. return tst[0].fetch('id')
  30. else
  31. return ''
  32. end
  33. end
  34. end
  35. end
Add Comment
Please, Sign In to add comment