diff options
author | Eileen Uchitelle <eileencodes@gmail.com> | 2019-01-24 09:51:02 -0500 |
---|---|---|
committer | Eileen Uchitelle <eileencodes@gmail.com> | 2019-01-25 09:56:43 -0500 |
commit | 1284f826cc2bba6edf956b581245c2d88e576056 (patch) | |
tree | ee517bd80ea8a798da756e7c78d5ae3e42677c68 /activerecord/lib/active_record/connection_handling.rb | |
parent | 1fecebae31029cf2287f2bae88e8730f00569778 (diff) | |
download | rails-1284f826cc2bba6edf956b581245c2d88e576056.tar.gz rails-1284f826cc2bba6edf956b581245c2d88e576056.tar.bz2 rails-1284f826cc2bba6edf956b581245c2d88e576056.zip |
Fix error raised when handler doesn't exist
While working on another feature for multiple databases (auto-switching)
I observed that in development the first request won't autoload the
application record connection for the primary database and may not yet
know about the replica connection.
In my test application this caused the application to thrown an error if
I tried to send the first request to the replica before the replica was
connected. This wouldn't be an issue in production because the
application is preloaded.
In order to fix this I decided to leave the original error message and
delete the new error message. I updated the original error message to
include the `role` to make it a bit clearer that the connection isn't
established for that particular role.
The error now reads:
```
No connection pool with 'primary' found for the 'reading' role.
```
A single database application will continue uisng the original error
message:
```
No connection pool with 'primary' found.
```
Diffstat (limited to 'activerecord/lib/active_record/connection_handling.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_handling.rb | 4 |
1 files changed, 0 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/connection_handling.rb b/activerecord/lib/active_record/connection_handling.rb index 4a941055d1..558cdeccf2 100644 --- a/activerecord/lib/active_record/connection_handling.rb +++ b/activerecord/lib/active_record/connection_handling.rb @@ -158,10 +158,6 @@ module ActiveRecord end def with_handler(handler_key, &blk) # :nodoc: - unless ActiveRecord::Base.connection_handlers.keys.include?(handler_key) - raise ArgumentError, "The #{handler_key} role does not exist. Add it by establishing a connection with `connects_to` or use an existing role (#{ActiveRecord::Base.connection_handlers.keys.join(", ")})." - end - handler = lookup_connection_handler(handler_key) swap_connection_handler(handler, &blk) end |