Skip to content

Commit

Permalink
Merge pull request #5339 from ghiculescu/rails-deprecation
Browse files Browse the repository at this point in the history
Fix deprecation warning on Rails 6.1

Related changes in Rails:
rails/rails#38256
rails/rails#38536
  • Loading branch information
carlosantoniodasilva authored Feb 3, 2021
2 parents 743b693 + 80423c8 commit 1bb5fcb
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions lib/generators/active_record/devise_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,24 @@ def rails5_and_up?
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
Expand Down

0 comments on commit 1bb5fcb

Please sign in to comment.