1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Merge pull request #5339 from ghiculescu/rails-deprecation

Fix deprecation warning on Rails 6.1

Related changes in Rails:
https://github.com/rails/rails/pull/38256
https://github.com/rails/rails/pull/38536
This commit is contained in:
Carlos Antonio da Silva 2021-02-02 21:27:31 -03:00 committed by GitHub
commit 1bb5fcbbec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -86,9 +86,24 @@ RUBY
Rails::VERSION::MAJOR >= 5
end
def rails61_and_up?
Rails::VERSION::MAJOR > 6 || (Rails::VERSION::MAJOR == 6 && Rails::VERSION::MINOR >= 1)
end
def postgresql?
config = ActiveRecord::Base.configurations[Rails.env]
config && config['adapter'] == 'postgresql'
ar_config && ar_config['adapter'] == 'postgresql'
end
def ar_config
if ActiveRecord::Base.configurations.respond_to?(:configs_for)
if rails61_and_up?
ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, name: "primary").configuration_hash
else
ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, spec_name: "primary").config
end
else
ActiveRecord::Base.configurations[Rails.env]
end
end
def migration_version