I have some code which relies on PGConn to connect to my database. However, I have an ActiveRecord connection already established.
Therefore, is there anyway I can get a PGConn from AR that I can use for the code in question?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think you’re looking for the #raw_connection method of
ActiveRecord::Base.connection:You can also fetch the connection particular to a model class from that class’s
connection:There’s a pretty good blog post by Daniel Azuma on the low-level connection API.
Hope this helps!