diff --git a/activerecord/lib/active_record/type_caster/connection.rb b/activerecord/lib/active_record/type_caster/connection.rb index 0626a7f7cbd46..fa2891859f169 100644 --- a/activerecord/lib/active_record/type_caster/connection.rb +++ b/activerecord/lib/active_record/type_caster/connection.rb @@ -19,7 +19,7 @@ def type_for_attribute(attr_name) if schema_cache.data_source_exists?(table_name) column = schema_cache.columns_hash(table_name)[attr_name.to_s] if column - type = @klass.lease_connection.lookup_cast_type_from_column(column) + type = @klass.with_connection { |connection| connection.lookup_cast_type_from_column(column) } end end