Guest User

Untitled

a guest
Jan 21st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. class ActiveRecord::Base
  2. class << self
  3. def postgresql_connection(config)
  4. require "arjdbc/postgresql"
  5. config[:host] ||= "localhost"
  6. config[:port] ||= 5432
  7. config[:url] ||= "jdbc:postgresql://#{config[:host]}:#{config[:port]}/#{config[:database]}"
  8. config[:url] << config[:pg_params] if config[:pg_params]
  9. config[:driver] ||= "org.postgresql.Driver"
  10. config[:adapter_spec] = ::ArJdbc::PostgreSQL
  11. conn = jdbc_connection(config)
  12. conn.execute("SET SEARCH_PATH TO #{config[:schema_search_path]}") if config[:schema_search_path]
  13. conn
  14. end
  15. alias_method :jdbcpostgresql_connection, :postgresql_connection
  16. end
  17. end
Add Comment
Please, Sign In to add comment