Skip to content

Commit

Permalink
[rails6][EvmDatabase] Fix .host
Browse files Browse the repository at this point in the history
Rails 6 changed database configuration to support multi-db environments:

rails/rails#33637

So how one accesses the `@config` hash has changed.

The original error suggested the following:

    NotImplementedError: `ActiveRecord::Base.configurations` in Rails 6
    now returns an object instead of a hash. The `fetch_path` method is
    not supported. Please use `configs_for` or consult the documentation
    for supported methods.

However, there is no `[]` or `host` method, so it would require calling
`configs_for(env_name: ENV["RAILS_ENV"]).config['host']`.

This solution seemed like the more terse solution.
  • Loading branch information
NickLaMuro committed Nov 24, 2020
1 parent fcac7da commit f2b6dc6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/evm_database.rb
Expand Up @@ -133,7 +133,7 @@ def self.seed_classes(classes)
private_class_method :seed_classes

def self.host
ActiveRecord::Base.configurations.fetch_path(ENV['RAILS_ENV'], 'host')
(ActiveRecord::Base.configurations[ENV['RAILS_ENV']] || {})['host']
end

def self.local?
Expand Down

0 comments on commit f2b6dc6

Please sign in to comment.