diff options
author | Arthur Neves <arthurnn@gmail.com> | 2016-05-04 14:05:31 -0500 |
---|---|---|
committer | Arthur Neves <arthurnn@gmail.com> | 2016-05-05 15:29:11 -0500 |
commit | 79154a3281eb25a573dfcb5d5db31c3c481311f9 (patch) | |
tree | c824f527cbead1f3e6bdaa452ace58b0fa3cceec /activerecord/lib/active_record | |
parent | c1bc0d83def740648fdbed05fcc3283dcef1f07d (diff) | |
download | rails-79154a3281eb25a573dfcb5d5db31c3c481311f9.tar.gz rails-79154a3281eb25a573dfcb5d5db31c3c481311f9.tar.bz2 rails-79154a3281eb25a573dfcb5d5db31c3c481311f9.zip |
Use spec key, when given as spec_id
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/connection_specification.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/connection_specification.rb index 5a18e95bcd..f8cdf3ca0c 100644 --- a/activerecord/lib/active_record/connection_adapters/connection_specification.rb +++ b/activerecord/lib/active_record/connection_adapters/connection_specification.rb @@ -164,7 +164,7 @@ module ActiveRecord # spec.config # # => { "host" => "localhost", "database" => "foo", "adapter" => "sqlite3" } # - def spec(config, id = "primary") + def spec(config, id = nil) spec = resolve(config).symbolize_keys raise(AdapterNotSpecified, "database configuration does not specify adapter") unless spec.key?(:adapter) @@ -179,6 +179,13 @@ module ActiveRecord end adapter_method = "#{spec[:adapter]}_connection" + + id ||= + if config.is_a?(Symbol) + config.to_s + else + "primary" + end ConnectionSpecification.new(id, spec, adapter_method) end |