instance method
active?
Ruby on Rails 3.0.20
Since v2.2.3Signature
active?()
Is this connection alive and ready for queries?
Source
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 251
def active?
if @connection.respond_to?(:status)
@connection.status == PGconn::CONNECTION_OK
else
# We're asking the driver, not Active Record, so use @connection.query instead of #query
@connection.query 'SELECT 1'
true
end
# postgres-pr raises a NoMethodError when querying if no connection is available.
rescue PGError, NoMethodError
false
end
Defined in activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb line 251
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::ConnectionAdapters::PostgreSQLAdapter