Is there a way to find out the server from an ActiveRecord connection?

I am using AR with SQLServer adapter on Rails2 / linux. In my local env, I can easily change freetds and odbc.ini files to track and find connection information. But under test conditions this information is constantly changing and out of sync, so I'm trying to include it in our log so that we can easily troubleshoot.

Yes, I know TinyTDS does it better, we are moving towards it, but not quite there yet.

I can do:

ActiveRecord::Base.connection.current_database

      

But can't find anything similar to get server address or ip.

+3


source to share


1 answer


I can't remember if there is a public API for this, but you can get AR config like this

ActiveRecord::Base.connection.instance_variable_get '@config'

      



this returns a configuration hash that includes the host

+2


source







All Articles