Method: ActiveRecord::ConnectionHandling#connection

Defined in:
activerecord/lib/active_record/connection_handling.rb

#connectionObject

Soft deprecated. Use #with_connection or #lease_connection instead.



260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# File 'activerecord/lib/active_record/connection_handling.rb', line 260

def connection
  pool = connection_pool
  if pool.permanent_lease?
    case ActiveRecord.permanent_connection_checkout
    when :deprecated
      ActiveRecord.deprecator.warn "        Called deprecated `ActiveRecord::Base.connection` method.\n\n        Either use `with_connection` or `lease_connection`.\n      MESSAGE\n    when :disallowed\n      raise ActiveRecordError, <<~MESSAGE\n        Called deprecated `ActiveRecord::Base.connection` method.\n\n        Either use `with_connection` or `lease_connection`.\n      MESSAGE\n    end\n    pool.lease_connection\n  else\n    pool.active_connection\n  end\nend\n"