aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/lib/active_storage/engine.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activestorage/lib/active_storage/engine.rb')
-rw-r--r--activestorage/lib/active_storage/engine.rb36
1 files changed, 18 insertions, 18 deletions
diff --git a/activestorage/lib/active_storage/engine.rb b/activestorage/lib/active_storage/engine.rb
index fc75a8f816..b27a027f3a 100644
--- a/activestorage/lib/active_storage/engine.rb
+++ b/activestorage/lib/active_storage/engine.rb
@@ -95,25 +95,25 @@ module ActiveStorage
end
initializer "active_storage.services" do
- ActiveSupport.on_load(:active_storage_blob) do
- if config_choice = Rails.configuration.active_storage.service
- configs = Rails.configuration.active_storage.service_configurations ||= begin
- config_file = Pathname.new(Rails.root.join("config/storage.yml"))
- raise("Couldn't find Active Storage configuration in #{config_file}") unless config_file.exist?
-
- require "yaml"
- require "erb"
-
- YAML.load(ERB.new(config_file.read).result) || {}
- rescue Psych::SyntaxError => e
- raise "YAML syntax error occurred while parsing #{config_file}. " \
- "Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
- "Error: #{e.message}"
- end
-
- ActiveStorage::Blob.service =
+ config.after_initialize do |app|
+ ActiveStorage.service_configurations = begin
+ config_file = Pathname.new(Rails.root.join("config/storage.yml"))
+ raise("Couldn't find Active Storage configuration in #{config_file}") unless config_file.exist?
+
+ require "yaml"
+ require "erb"
+
+ YAML.load(ERB.new(config_file.read).result) || {}
+ rescue Psych::SyntaxError => e
+ raise "YAML syntax error occurred while parsing #{config_file}. " \
+ "Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
+ "Error: #{e.message}"
+ end
+
+ if global_service_name = app.config.active_storage.service
+ ActiveStorage.service =
begin
- ActiveStorage::Service.configure config_choice, configs
+ ActiveStorage::Service.configure(global_service_name)
rescue => e
raise e, "Cannot load `Rails.config.active_storage.service`:\n#{e.message}", e.backtrace
end