diff options
author | eileencodes <eileencodes@gmail.com> | 2019-07-25 11:35:44 -0400 |
---|---|---|
committer | eileencodes <eileencodes@gmail.com> | 2019-07-25 11:35:44 -0400 |
commit | 1d83ab936672790ea3abd407df8c16d696aaef70 (patch) | |
tree | b37ac0823379cc429121c8dc6bd913c940514be0 /activerecord | |
parent | 55eba62a1074a4c1e70a9b96b78b3dbf812f5e9a (diff) | |
download | rails-1d83ab936672790ea3abd407df8c16d696aaef70.tar.gz rails-1d83ab936672790ea3abd407df8c16d696aaef70.tar.bz2 rails-1d83ab936672790ea3abd407df8c16d696aaef70.zip |
Make sure AR can load without Rails
In #36560 I accidentally re-introduced a bug where ActiveRecord can't be
used without Rails. This returns an empty hash if we're outside the
context of Rails since we can't create the database tasks without
loading and reading the database yaml which is something only Railties
can do.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/tasks/database_tasks.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/tasks/database_tasks.rb b/activerecord/lib/active_record/tasks/database_tasks.rb index a78bebf764..5d1ce19829 100644 --- a/activerecord/lib/active_record/tasks/database_tasks.rb +++ b/activerecord/lib/active_record/tasks/database_tasks.rb @@ -154,6 +154,8 @@ module ActiveRecord end def for_each(databases) + return {} unless defined?(Rails) + database_configs = ActiveRecord::DatabaseConfigurations.new(databases).configs_for(env_name: Rails.env) # if this is a single database application we don't want tasks for each primary database |