Skip to content

Commit

Permalink
Merge pull request #94 from FundingCircle/fix-deprecation-warning
Browse files Browse the repository at this point in the history
Fix deprecation warning when using connection_config
  • Loading branch information
bliof-fc authored Nov 20, 2023
2 parents be401b3 + 83ca019 commit 4f54148
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
15 changes: 15 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@ steps:
- build_rails51
- build_rails52

- name: build_rails7
image: ruby:3.0-alpine
environment:
BUNDLE_GEMFILE: gemfiles/rails_7.gemfile
DISABLE_DATABASE_ENVIRONMENT_CHECK: 1
<<: [*vault_tag, *artifactory_credentials]
commands: *commands
depends_on:
- build_rails4
- build_rails5
- build_rails51
- build_rails52
- build_rails6

- name: publish_feature_branch_gem
image: quay.io/fundingcircle/alpine-ruby-builder:2.7
environment:
Expand All @@ -111,6 +125,7 @@ steps:
- build_rails51
- build_rails52
- build_rails6
- build_rails7
when:
branch:
exclude:
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Vault Rails Changelog

## 2.1.2 (September 8, 2023)
## 2.1.2 (November 17, 2023)

IMPROVEMENTS
- Add Rails 7 Support
- Fix "DEPRECATION WARNING: connection_config is deprecated and will be removed from Rails 7.0"

## 2.1.1 (January 31, 2022)

Expand Down
8 changes: 5 additions & 3 deletions lib/vault/latest/encrypted_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,12 @@ def _vault_fetch_attribute_type(options)
attribute_type = options.fetch(:type, ActiveRecord::Type::Value.new)

if attribute_type.is_a?(Symbol)
if ActiveRecord::Base.connection_config[:adapter]
ActiveRecord::Type.lookup(attribute_type, adapter: ActiveRecord::Base.connection_config[:adapter])
adapter = ActiveRecord::Base.try(:connection_db_config).try(:adapter) || (ActiveRecord::Base.try(:connection_config) || {})[:adapter]

if adapter
ActiveRecord::Type.lookup(attribute_type, adapter: adapter)
else
ActiveRecord::Type.lookup(attribute_type) # This call does a db connection, best find a way to configure `ActiveRecord::Base.connection_config[:adapter]`
ActiveRecord::Type.lookup(attribute_type) # This call does a db connection, best find a way to configure the adapter
end
else
ActiveModel::Type::Value.new
Expand Down
2 changes: 1 addition & 1 deletion lib/vault/rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Vault
module Rails
VERSION = "2.1.1"
VERSION = '2.1.2'

def self.latest?
ActiveRecord.version >= Gem::Version.new('5.0.0')
Expand Down

0 comments on commit 4f54148

Please sign in to comment.