instance method
connection
Ruby on Rails 8.0.4
Since v4.0.13Signature
connection()
Soft deprecated. Use #with_connection or #lease_connection instead.
Source
# File activerecord/lib/active_record/connection_handling.rb, line 276
def connection
pool = connection_pool
if pool.permanent_lease?
case ActiveRecord.permanent_connection_checkout
when :deprecated
ActiveRecord.deprecator.warn <<~MESSAGE
Called deprecated `ActiveRecord::Base.connection` method.
Either use `with_connection` or `lease_connection`.
MESSAGE
when :disallowed
raise ActiveRecordError, <<~MESSAGE
Called deprecated `ActiveRecord::Base.connection` method.
Either use `with_connection` or `lease_connection`.
MESSAGE
end
pool.lease_connection
else
pool.active_connection
end
end
Defined in activerecord/lib/active_record/connection_handling.rb line 276
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::ConnectionHandling