Guest User

Untitled

a guest
Mar 4th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. class External < ActiveRecord::Base
  2. self.abstract_class = true
  3.  
  4. # Setup connection for an account through a Norad resource
  5. def self.use_account(account_id)
  6. return true unless ['staging', 'production'].include?(RAILS_ENV)
  7. return false unless resource = Resource.find(:first,
  8. :conditions => ['account_id = ?', account_id])
  9.  
  10. self.establish_connection(
  11. :adapter => "mysql",
  12. :host => resource.hostname,
  13. :username => resource.username,
  14. :password => resource.password,
  15. :database => resource.database
  16. )
  17. end
  18. end
Add Comment
Please, Sign In to add comment